From 23a134c96eba93f9b124b03f6325866615236ba0 Mon Sep 17 00:00:00 2001 From: Mia Winter Date: Sat, 18 Nov 2023 16:09:50 +0100 Subject: [PATCH] fixed: login/logout not working with razor components --- Pages/Login.cshtml.cs | 3 ++- Pages/Logout.cshtml.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Pages/Login.cshtml.cs b/Pages/Login.cshtml.cs index c6deb96..4daba60 100644 --- a/Pages/Login.cshtml.cs +++ b/Pages/Login.cshtml.cs @@ -1,3 +1,4 @@ + using System.Security.Claims; using JustShortIt.Model; using Microsoft.AspNetCore.Authentication; @@ -42,7 +43,7 @@ public class LoginModel : PageModel { new ClaimsPrincipal(identity), properties); - return RedirectToPage("Urls"); + return LocalRedirect("~/urls"); } ModelState.AddModelError(string.Empty, "Invalid Username or Password"); diff --git a/Pages/Logout.cshtml.cs b/Pages/Logout.cshtml.cs index e3da974..84f8a56 100644 --- a/Pages/Logout.cshtml.cs +++ b/Pages/Logout.cshtml.cs @@ -8,6 +8,6 @@ namespace JustShortIt.Pages; public class LogoutModel : PageModel { public async Task OnGetAsync() { await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); - return RedirectToPage("Index"); + return LocalRedirect("~/"); } } \ No newline at end of file