Refaktorierung des HomeController zur Verbesserung der Fehlerbehandlung, des Authentifizierungsprozesses und der Verwaltung der Benutzersprache.

This commit is contained in:
Developer 02
2024-05-24 13:42:20 +02:00
parent b60ae62779
commit b594ddb646
2 changed files with 10 additions and 7 deletions

View File

@@ -164,7 +164,8 @@ namespace EnvelopeGenerator.Web.Controllers
var claimsIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
var authProperties = new AuthenticationProperties {
AllowRefresh = false
AllowRefresh = false,
IsPersistent = false
};
await HttpContext.SignInAsync(
@@ -187,14 +188,17 @@ namespace EnvelopeGenerator.Web.Controllers
else
{
database.Services.actionService.EnterIncorrectAccessCode(response.Envelope, response.Receiver); //for history
return Unauthorized();
Response.StatusCode = StatusCodes.Status401Unauthorized;
return View("EnvelopeLocked")
.WithData("UserLanguage", UserLanguage ?? _cultures.Default.Language);
}
},
Fail: (messages, notices) =>
{
_logger.LogNotice(notices);
return Unauthorized();
Response.StatusCode = StatusCodes.Status401Unauthorized;
return View("EnvelopeLocked")
.WithData("UserLanguage", UserLanguage ?? _cultures.Default.Language);
});
}
catch(Exception ex)