i forgor, the verify route for krsdk

This commit is contained in:
rfi 2023-10-15 12:07:04 +07:00
parent 133c4817b7
commit f5ef33f16a
2 changed files with 35 additions and 0 deletions

View File

@ -75,6 +75,38 @@ namespace AscNet.SDKServer.Controllers
account
});
});
app.MapPost("/api/AscNet/verify", (HttpContext ctx) =>
{
AuthRequest? req = JsonConvert.DeserializeObject<AuthRequest>(Encoding.UTF8.GetString(ctx.Request.BodyReader.ReadAsync().Result.Buffer));
if (req is null || req.Token == string.Empty)
{
return JsonConvert.SerializeObject(new
{
code = -1,
msg = "Invalid request"
});
}
Account? account = Account.FromToken(req.Token);
if (account == null)
{
return JsonConvert.SerializeObject(new
{
code = -1,
msg = "Invalid credentials!"
});
}
return JsonConvert.SerializeObject(new
{
code = 0,
msg = "OK",
account
});
});
}
}
}

View File

@ -10,5 +10,8 @@ namespace AscNet.SDKServer.Models
[JsonProperty("password", NullValueHandling = NullValueHandling.Ignore)]
public string Password { get; set; }
[JsonProperty("token", NullValueHandling = NullValueHandling.Ignore)]
public string Token { get; set; }
}
}