mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Added re-authentication modal
This commit is contained in:
@@ -166,6 +166,7 @@ public class HomeController : Controller
|
||||
|
||||
return RedirectToAction("Index", "Home");
|
||||
}
|
||||
Response.StatusCode = 500;
|
||||
switch (authenticationResult.AuthenticationState)
|
||||
{
|
||||
case UserNotAuthenticatedReason.InvalidCredentials:
|
||||
@@ -198,4 +199,18 @@ public class HomeController : Controller
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("RemainingTime")]
|
||||
public async Task<IActionResult> GetRemainingSessionTime()
|
||||
{
|
||||
var result = await HttpContext.AuthenticateAsync(CookieAuthenticationDefaults.AuthenticationScheme);
|
||||
|
||||
if (!result.Succeeded || result.Properties?.ExpiresUtc == null)
|
||||
return Json(new { remainingMinutes = 0 });
|
||||
|
||||
var remaining = result.Properties.ExpiresUtc.Value - DateTimeOffset.UtcNow;
|
||||
return Json(new { remainingMinutes = (int) Math.Ceiling(remaining.TotalMinutes) });
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user