From ce201207d471fe87d0a764aeaeab85e6b417573f Mon Sep 17 00:00:00 2001 From: limited_dev Date: Mon, 12 Jun 2023 20:46:44 +0200 Subject: [PATCH] NOTE: temp commit, started rolling back changes to auth system Signed-off-by: limited_dev --- .../Auth/CustomAuthenticationStateProvider.cs | 12 ++-- .../ClickOn/ClickOnResetPassword.razor | 14 ++--- .../Pages/Accounts/Login.razor | 12 ++-- .../Pages/Accounts/Register.razor | 23 ++++---- .../Pages/Accounts/ResetPassword.razor | 11 ++-- .../Pages/Accounts/UserPage.razor | 56 ++++++++++++++++--- .../Pages/Accounts/UserPage.razor.css | 0 .../Pages/Basic/ReportPage.razor | 13 +++-- .../Pages/Moderation/ModMenu.razor | 5 -- .../Shared/Components/Comment.razor | 4 +- .../Shared/Components/Forms/CommentForm.razor | 4 +- .../Shared/Components/Forms/PostForm.razor | 4 +- .../Shared/Components/Post.razor | 2 +- 13 files changed, 97 insertions(+), 63 deletions(-) create mode 100644 ImageBoardServerApp/Pages/Accounts/UserPage.razor.css diff --git a/ImageBoardServerApp/Auth/CustomAuthenticationStateProvider.cs b/ImageBoardServerApp/Auth/CustomAuthenticationStateProvider.cs index 65bef1e..06256c0 100644 --- a/ImageBoardServerApp/Auth/CustomAuthenticationStateProvider.cs +++ b/ImageBoardServerApp/Auth/CustomAuthenticationStateProvider.cs @@ -27,15 +27,15 @@ public class CustomAuthenticationStateProvider : AuthenticationStateProvider var claimsPrincipal = new ClaimsPrincipal(new ClaimsIdentity(new List { //new Claim(ClaimTypes.Email, userSession.Email), - new Claim(ClaimTypes.Name, userSession.UserID.ToString()), + new Claim(ClaimTypes.Name, userSession.Email), new Claim(ClaimTypes.Role, userSession.Role) }, "CustomAuth")); - return new AuthenticationState(claimsPrincipal); + return await Task.FromResult(new AuthenticationState(claimsPrincipal)); } catch { - Console.WriteLine("Returned Anon Auth due to err"); - return new AuthenticationState(_anonymous); + Console.WriteLine("Resorting to Anon"); + return await Task.FromResult(new AuthenticationState(_anonymous)); } } @@ -48,8 +48,8 @@ public class CustomAuthenticationStateProvider : AuthenticationStateProvider await _sessionStorage.SetAsync("UserSession", session); claimsPrincipal = new ClaimsPrincipal(new ClaimsIdentity(new List { - new Claim(ClaimTypes.Email, session.UserID.ToString()), - new Claim(ClaimTypes.Email, session.Role) + new Claim(ClaimTypes.Name, session.Email), + new Claim(ClaimTypes.Role, session.Role) })); } else diff --git a/ImageBoardServerApp/Pages/Accounts/ClickOn/ClickOnResetPassword.razor b/ImageBoardServerApp/Pages/Accounts/ClickOn/ClickOnResetPassword.razor index 27a2051..c9f5592 100644 --- a/ImageBoardServerApp/Pages/Accounts/ClickOn/ClickOnResetPassword.razor +++ b/ImageBoardServerApp/Pages/Accounts/ClickOn/ClickOnResetPassword.razor @@ -9,11 +9,11 @@