summaryrefslogtreecommitdiffstats
path: root/api/WhatApi/Endpoints/LoginEndpoint.cs
diff options
context:
space:
mode:
Diffstat (limited to 'api/WhatApi/Endpoints/LoginEndpoint.cs')
-rw-r--r--api/WhatApi/Endpoints/LoginEndpoint.cs5
1 files changed, 3 insertions, 2 deletions
diff --git a/api/WhatApi/Endpoints/LoginEndpoint.cs b/api/WhatApi/Endpoints/LoginEndpoint.cs
index ee697ef..cb76696 100644
--- a/api/WhatApi/Endpoints/LoginEndpoint.cs
+++ b/api/WhatApi/Endpoints/LoginEndpoint.cs
@@ -13,8 +13,9 @@ public class LoginEndpoint(AppDatabase db, IConfiguration configuration) : BaseE
public required string Password { get; set; }
}
+ [AllowAnonymous]
[HttpPost("~/login")]
- public async Task<ActionResult> HandleAsync(LoginRequest login, CancellationToken ct = default) {
+ public async Task<ActionResult> HandleAsync([FromForm] LoginRequest login, CancellationToken ct = default) {
var user = await db.Users.FirstOrDefaultAsync(c => c.Name == login.Username, ct);
if (user?.PasswordHash is null) return Unauthorized();
@@ -47,6 +48,6 @@ public class LoginEndpoint(AppDatabase db, IConfiguration configuration) : BaseE
var tokenString = tokenHandler.WriteToken(token);
user.SetLastSeen();
await db.SaveChangesAsync(ct);
- return Ok(tokenString);
+ return Redirect("what://lcb?code=" + tokenString);
}
} \ No newline at end of file