diff --git a/Net.Vatprc.Uniapi/Controllers/AuthController.cs b/Net.Vatprc.Uniapi/Controllers/AuthController.cs
index b039365..7b8069d 100644
--- a/Net.Vatprc.Uniapi/Controllers/AuthController.cs
+++ b/Net.Vatprc.Uniapi/Controllers/AuthController.cs
@@ -211,7 +211,7 @@ protected IActionResult RenderDeviceCodeUI(string? user_code)
-
@@ -245,19 +246,17 @@ protected IActionResult RenderDeviceCodeUI(string? user_code)
[HttpGet("device")]
[ApiExplorerSettings(IgnoreApi = true)]
- public IActionResult DeviceConfirm([FromQuery] string? user_code)
+ public async Task DeviceConfirm([FromQuery] string? user_code, [FromQuery] bool confirm)
{
ClearCookies();
- return RenderDeviceCodeUI(user_code);
- }
-
+ if (!confirm)
+ {
+ return RenderDeviceCodeUI(user_code);
+ }
- [HttpPost("device")]
- [ApiExplorerSettings(IgnoreApi = true)]
- public async Task DeviceStart([FromForm(Name = "user_code")] string user_code)
- {
+ var code = NormalizeUserCode(user_code);
var deviceAuthz = await DbContext.DeviceAuthorization
- .FirstOrDefaultAsync(x => x.UserCode == user_code);
+ .FirstOrDefaultAsync(x => x.UserCode == code);
if (deviceAuthz == null)
{
return RenderCallbackUI("Error", "Invalid code", "The code provided is not found in our records.", Url.Action(nameof(DeviceConfirm)));
@@ -274,7 +273,7 @@ public async Task DeviceStart([FromForm(Name = "user_code")] stri
await DbContext.SaveChangesAsync();
return RenderCallbackUI("Error", "Invalid code", "The code provided is expired.", Url.Action(nameof(DeviceConfirm)));
}
- Response.Cookies.Append("user_code", user_code, new CookieOptions
+ Response.Cookies.Append("user_code", code, new CookieOptions
{
HttpOnly = true,
Secure = true,