Add JWT auth, token service & Neutrino endpoint
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using API.Contracts.Neutrino.Enums;
|
||||
|
||||
namespace API.Contracts.Neutrino.Responses;
|
||||
|
||||
// {"ResultCode":1,"UserId":"their user id","Nickname":"splotybean"}
|
||||
public class NeutrinoAuthenticateResponse : NeutrinoResultCodeResponse
|
||||
{
|
||||
public static NeutrinoAuthenticateResponse Success(string userId, string nickname) => new()
|
||||
{
|
||||
ResultCode = (byte)AuthenticationResultCode.AuthenticationSuccessful,
|
||||
UserId = userId,
|
||||
Nickname = nickname
|
||||
};
|
||||
|
||||
public static NeutrinoAuthenticateResponse Failure(AuthenticationResultCode error) => new()
|
||||
{
|
||||
ResultCode = (byte)error
|
||||
};
|
||||
|
||||
[JsonPropertyName(name: "UserId")]
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? UserId { get; set; }
|
||||
|
||||
[JsonPropertyName(name: "Nickname")]
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Nickname { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace API.Contracts.Neutrino.Responses;
|
||||
|
||||
public class NeutrinoResultCodeResponse
|
||||
{
|
||||
public static NeutrinoResultCodeResponse Success() => new NeutrinoResultCodeResponse
|
||||
{
|
||||
ResultCode = 0
|
||||
};
|
||||
|
||||
public static NeutrinoResultCodeResponse Failure(byte resultCode, string? message = null)
|
||||
{
|
||||
return new NeutrinoResultCodeResponse
|
||||
{
|
||||
Message = message,
|
||||
ResultCode = resultCode
|
||||
};
|
||||
}
|
||||
|
||||
[JsonPropertyName(name: "Data")]
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Data { get; set; }
|
||||
|
||||
[JsonPropertyName(name: "Message")]
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Message { get; set; }
|
||||
|
||||
[JsonPropertyName(name: "ResultCode")]
|
||||
public byte ResultCode { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user