From 8c355b82df02bc650c5ba101d838121f485e8581 Mon Sep 17 00:00:00 2001 From: ivar Date: Thu, 4 Dec 2025 23:30:39 +0100 Subject: Improve login experience --- api/WhatApi/Endpoints/LoginEndpoint.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'api/WhatApi/Endpoints/LoginEndpoint.cs') 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 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(Constants.Env.TokenEntropy); -- cgit v1.3