summaryrefslogtreecommitdiffstats
path: root/api/WhatApi/Endpoints
diff options
context:
space:
mode:
authorivar <i@oiee.no>2025-12-04 23:30:39 +0100
committerivar <i@oiee.no>2025-12-04 23:30:39 +0100
commit8c355b82df02bc650c5ba101d838121f485e8581 (patch)
tree00ff527de5968d7899f7f653355073b8a416328b /api/WhatApi/Endpoints
parentdeade767eace22a8c5281dcd5360c300395e2b5e (diff)
downloadwhat-master.tar.xz
what-master.zip
Improve login experienceHEADmaster
Diffstat (limited to 'api/WhatApi/Endpoints')
-rw-r--r--api/WhatApi/Endpoints/GetLoginPageEndpoint.cs6
-rw-r--r--api/WhatApi/Endpoints/GetMapPageEndpoint.cs2
-rw-r--r--api/WhatApi/Endpoints/GetUploadPageEndpoint.cs2
-rw-r--r--api/WhatApi/Endpoints/LoginEndpoint.cs4
4 files changed, 8 insertions, 6 deletions
diff --git a/api/WhatApi/Endpoints/GetLoginPageEndpoint.cs b/api/WhatApi/Endpoints/GetLoginPageEndpoint.cs
index dd17669..8b07a0e 100644
--- a/api/WhatApi/Endpoints/GetLoginPageEndpoint.cs
+++ b/api/WhatApi/Endpoints/GetLoginPageEndpoint.cs
@@ -6,7 +6,9 @@ public class GetLoginPageEndpoint : BaseEndpoint
{
[AllowAnonymous]
[HttpGet("~/login")]
- public ActionResult Handle() {
- return Content(TemplateFulfiller.WebLoginPage(), "text/html");
+ public ActionResult Handle(string? error = null) {
+ return Content(TemplateFulfiller.WebLoginPage(new TemplateFulfiller.WebLoginModel() {
+ Error = error ?? string.Empty
+ }), "text/html");
}
} \ No newline at end of file
diff --git a/api/WhatApi/Endpoints/GetMapPageEndpoint.cs b/api/WhatApi/Endpoints/GetMapPageEndpoint.cs
index 833a98c..bafad6a 100644
--- a/api/WhatApi/Endpoints/GetMapPageEndpoint.cs
+++ b/api/WhatApi/Endpoints/GetMapPageEndpoint.cs
@@ -6,7 +6,7 @@ public class GetMapPageEndpoint : BaseEndpoint
{
[HttpGet("~/map")]
- public ActionResult GetMapPage() {
+ public ActionResult Handle() {
return Content(TemplateFulfiller.WebMapPage(), "text/html");
}
} \ No newline at end of file
diff --git a/api/WhatApi/Endpoints/GetUploadPageEndpoint.cs b/api/WhatApi/Endpoints/GetUploadPageEndpoint.cs
index ea14819..309fa49 100644
--- a/api/WhatApi/Endpoints/GetUploadPageEndpoint.cs
+++ b/api/WhatApi/Endpoints/GetUploadPageEndpoint.cs
@@ -6,7 +6,7 @@ public class GetUploadPageEndpoint : BaseEndpoint
{
[HttpGet("~/upload")]
- public ActionResult GetMapPage() {
+ public ActionResult Handle() {
return Content(TemplateFulfiller.WebUploadPage(), "text/html");
}
} \ No newline at end of file
diff --git a/api/WhatApi/Endpoints/LoginEndpoint.cs b/api/WhatApi/Endpoints/LoginEndpoint.cs
index cb76696..470ef34 100644
--- a/api/WhatApi/Endpoints/LoginEndpoint.cs
+++ b/api/WhatApi/Endpoints/LoginEndpoint.cs
@@ -17,10 +17,10 @@ public class LoginEndpoint(AppDatabase db, IConfiguration configuration) : BaseE
[HttpPost("~/login")]
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();
+ if (user?.PasswordHash is null) return Redirect("/login?error=Ukjent bruker/passord");
var verificationResult = PasswordHasher.VerifyHashedPassword(user.PasswordHash, login.Password);
- if (verificationResult == PasswordVerificationResult.Failed) return Unauthorized();
+ if (verificationResult == PasswordVerificationResult.Failed) return Redirect("/login?error=Ukjent bruker/passord");
var tokenEntropy = configuration.GetValue<string>(Constants.Env.TokenEntropy);