diff --git a/TalentBlazor/Data/ApplicationDbContext.cs b/TalentBlazor.ServiceInterface/Data/ApplicationDbContext.cs similarity index 65% rename from TalentBlazor/Data/ApplicationDbContext.cs rename to TalentBlazor.ServiceInterface/Data/ApplicationDbContext.cs index 828be16..c9e2a69 100644 --- a/TalentBlazor/Data/ApplicationDbContext.cs +++ b/TalentBlazor.ServiceInterface/Data/ApplicationDbContext.cs @@ -1,9 +1,9 @@ using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; -using TalentBlazor.ServiceModel; namespace TalentBlazor.Data; -public class ApplicationDbContext(DbContextOptions options) : IdentityDbContext(options) +public class ApplicationDbContext(DbContextOptions options) + : IdentityDbContext(options) { -} +} \ No newline at end of file diff --git a/TalentBlazor.ServiceInterface/Data/CustomUserSession.cs b/TalentBlazor.ServiceInterface/Data/CustomUserSession.cs new file mode 100644 index 0000000..84c4adf --- /dev/null +++ b/TalentBlazor.ServiceInterface/Data/CustomUserSession.cs @@ -0,0 +1,42 @@ +using System.Security.Claims; +using Microsoft.AspNetCore.Identity; +using Microsoft.Extensions.Options; +using ServiceStack; +using ServiceStack.Web; + +namespace TalentBlazor.Data; + +public class CustomUserSession : AuthUserSession +{ + public override void PopulateFromClaims(IRequest httpReq, ClaimsPrincipal principal) + { + // Populate Session with data from Identity Auth Claims + ProfileUrl = principal.FindFirstValue(JwtClaimTypes.Picture); + } +} + +/// +/// Add additional claims to the Identity Auth Cookie +/// +public class AdditionalUserClaimsPrincipalFactory( + UserManager userManager, + RoleManager roleManager, + IOptions optionsAccessor) + : UserClaimsPrincipalFactory(userManager, roleManager, optionsAccessor) +{ + public override async Task CreateAsync(ApplicationUser user) + { + var principal = await base.CreateAsync(user); + var identity = (ClaimsIdentity)principal.Identity!; + + var claims = new List(); + // Add additional claims here + if (user.ProfileUrl != null) + { + claims.Add(new Claim(JwtClaimTypes.Picture, user.ProfileUrl)); + } + + identity.AddClaims(claims); + return principal; + } +} diff --git a/TalentBlazor.ServiceInterface/TalentBlazor.ServiceInterface.csproj b/TalentBlazor.ServiceInterface/TalentBlazor.ServiceInterface.csproj index 417e025..a91d50f 100644 --- a/TalentBlazor.ServiceInterface/TalentBlazor.ServiceInterface.csproj +++ b/TalentBlazor.ServiceInterface/TalentBlazor.ServiceInterface.csproj @@ -7,6 +7,8 @@ + + diff --git a/TalentBlazor.ServiceModel/AppUser.cs b/TalentBlazor.ServiceModel/ApplicationUser.cs similarity index 91% rename from TalentBlazor.ServiceModel/AppUser.cs rename to TalentBlazor.ServiceModel/ApplicationUser.cs index bb87ac6..3f7704f 100644 --- a/TalentBlazor.ServiceModel/AppUser.cs +++ b/TalentBlazor.ServiceModel/ApplicationUser.cs @@ -5,8 +5,9 @@ using System.Collections.Generic; using System.Runtime.Serialization; using Microsoft.AspNetCore.Identity; +using TalentBlazor.ServiceModel; -namespace TalentBlazor.ServiceModel; +namespace TalentBlazor.Data; [Icon(Svg = Icons.AppUser)] [Alias("AspNetUsers")] @@ -21,4 +22,3 @@ public class ApplicationUser : IdentityUser [Input(Type = "file"), UploadTo("users")] public string? ProfileUrl { get; set; } } - diff --git a/TalentBlazor.ServiceModel/Talent.cs b/TalentBlazor.ServiceModel/Talent.cs index 9da509e..1d0de40 100644 --- a/TalentBlazor.ServiceModel/Talent.cs +++ b/TalentBlazor.ServiceModel/Talent.cs @@ -2,6 +2,7 @@ using ServiceStack.DataAnnotations; using System; using System.Collections.Generic; +using TalentBlazor.Data; namespace TalentBlazor.ServiceModel; diff --git a/TalentBlazor.ServiceModel/TalentBlazor.ServiceModel.csproj b/TalentBlazor.ServiceModel/TalentBlazor.ServiceModel.csproj index 81cc5db..532bd0e 100644 --- a/TalentBlazor.ServiceModel/TalentBlazor.ServiceModel.csproj +++ b/TalentBlazor.ServiceModel/TalentBlazor.ServiceModel.csproj @@ -7,7 +7,7 @@ - + @@ -19,10 +19,4 @@ - - - ..\..\..\..\..\Program Files\dotnet\shared\Microsoft.AspNetCore.App\8.0.0-rc.2.23480.2\Microsoft.Extensions.Identity.Stores.dll - - - diff --git a/TalentBlazor/Components/App.razor b/TalentBlazor/Components/App.razor index ed82668..ad13a02 100644 --- a/TalentBlazor/Components/App.razor +++ b/TalentBlazor/Components/App.razor @@ -23,7 +23,7 @@ - + diff --git a/TalentBlazor/Components/Identity/ExternalLoginPicker.razor b/TalentBlazor/Components/Identity/ExternalLoginPicker.razor index 8492065..7d43811 100644 --- a/TalentBlazor/Components/Identity/ExternalLoginPicker.razor +++ b/TalentBlazor/Components/Identity/ExternalLoginPicker.razor @@ -11,9 +11,9 @@ {

- There are no external authentication services configured. - See this article - about setting up this ASP.NET application to support logging in via external services. + There are no external authentication services configured. + See this article + about setting up this ASP.NET application to support logging in via external services.

} @@ -26,7 +26,7 @@ else
@foreach (var provider in _externalLogins!) { - + }
diff --git a/TalentBlazor/Components/Identity/LogoutForm.razor b/TalentBlazor/Components/Identity/LogoutForm.razor index e53fce4..1cc0145 100644 --- a/TalentBlazor/Components/Identity/LogoutForm.razor +++ b/TalentBlazor/Components/Identity/LogoutForm.razor @@ -33,7 +33,7 @@ if (SignInManager.IsSignedIn(user)) { await SignInManager.SignOutAsync(); - RedirectManager.RedirectTo(ReturnUrl ?? "/"); + RedirectManager.RedirectTo(ReturnUrl ?? "/Account/Logout"); } } } diff --git a/TalentBlazor/Components/Identity/ShowRecoveryCodes.razor b/TalentBlazor/Components/Identity/ShowRecoveryCodes.razor index f0683d0..41a9bfe 100644 --- a/TalentBlazor/Components/Identity/ShowRecoveryCodes.razor +++ b/TalentBlazor/Components/Identity/ShowRecoveryCodes.razor @@ -1,4 +1,4 @@ -

Recovery codes

+Recovery codes
diff --git a/TalentBlazor/Components/Layout/ManageLayout.razor b/TalentBlazor/Components/Layout/ManageLayout.razor index 3c8de9c..d1e5c95 100644 --- a/TalentBlazor/Components/Layout/ManageLayout.razor +++ b/TalentBlazor/Components/Layout/ManageLayout.razor @@ -1,11 +1,11 @@ @inherits LayoutComponentBase @layout MainLayout -

Manage your account

-
-

Change your account settings

-
+
+ Manage your account + Change your account settings +
@@ -15,3 +15,4 @@
+ diff --git a/TalentBlazor/Components/Pages/Account/AccessDenied.razor b/TalentBlazor/Components/Pages/Account/AccessDenied.razor index 77ead44..3300471 100644 --- a/TalentBlazor/Components/Pages/Account/AccessDenied.razor +++ b/TalentBlazor/Components/Pages/Account/AccessDenied.razor @@ -3,11 +3,13 @@ Access Denied -

Access Denied

+
+

Access Denied

-

- You do not have access to this resource. -

+

+ You do not have access to this resource. +

+
@code { [Parameter] public string ReturnUrl { get; set; } diff --git a/TalentBlazor/Components/Pages/Account/ConfirmEmail.razor b/TalentBlazor/Components/Pages/Account/ConfirmEmail.razor index 59bbe3e..44bbb8b 100644 --- a/TalentBlazor/Components/Pages/Account/ConfirmEmail.razor +++ b/TalentBlazor/Components/Pages/Account/ConfirmEmail.razor @@ -1,4 +1,4 @@ -@page "/Account/ConfirmEmail" +@page "/Account/ConfirmEmail" @using System.Text @using Microsoft.AspNetCore.Identity @@ -11,9 +11,9 @@ Confirm email -

Confirm email

+
+ Confirm email -
diff --git a/TalentBlazor/Components/Pages/Account/ConfirmEmailChange.razor b/TalentBlazor/Components/Pages/Account/ConfirmEmailChange.razor index 100b6a5..a7f6583 100644 --- a/TalentBlazor/Components/Pages/Account/ConfirmEmailChange.razor +++ b/TalentBlazor/Components/Pages/Account/ConfirmEmailChange.razor @@ -1,4 +1,4 @@ -@page "/Account/ConfirmEmailChange" +@page "/Account/ConfirmEmailChange" @using System.Text @using Microsoft.AspNetCore.Identity @@ -13,9 +13,9 @@ Confirm email change -

Confirm email change

+Confirm email change -
+
diff --git a/TalentBlazor/Components/Pages/Account/ExternalLogin.razor b/TalentBlazor/Components/Pages/Account/ExternalLogin.razor index dabba53..77636db 100644 --- a/TalentBlazor/Components/Pages/Account/ExternalLogin.razor +++ b/TalentBlazor/Components/Pages/Account/ExternalLogin.razor @@ -25,9 +25,9 @@ Register
- -

Register

-

Associate your @providerDisplayName account.

+ + Register + Associate your @providerDisplayName account. You've successfully authenticated with @providerDisplayName. @@ -39,18 +39,18 @@
- +
- +
- +
- +
- + Register
diff --git a/TalentBlazor/Components/Pages/Account/ForgotPassword.razor b/TalentBlazor/Components/Pages/Account/ForgotPassword.razor index c6cfb6c..5c97082 100644 --- a/TalentBlazor/Components/Pages/Account/ForgotPassword.razor +++ b/TalentBlazor/Components/Pages/Account/ForgotPassword.razor @@ -1,4 +1,4 @@ -@page "/Account/ForgotPassword" +@page "/Account/ForgotPassword" @using System.ComponentModel.DataAnnotations @using System.Text @@ -16,23 +16,23 @@ Forgot your password? -
-

Forgot your password?

-

Enter your email.

+
+ Forgot your password? + Enter your email. - +
- +
- +
- +
- + Reset password
diff --git a/TalentBlazor/Components/Pages/Account/ForgotPasswordConfirmation.razor b/TalentBlazor/Components/Pages/Account/ForgotPasswordConfirmation.razor index b28d4cb..cbcf33e 100644 --- a/TalentBlazor/Components/Pages/Account/ForgotPasswordConfirmation.razor +++ b/TalentBlazor/Components/Pages/Account/ForgotPasswordConfirmation.razor @@ -2,8 +2,11 @@ Forgot password confirmation -

Forgot password confirmation

+
+ Forgot password confirmation + +

+ Please check your email to reset your password. +

+
-

- Please check your email to reset your password. -

diff --git a/TalentBlazor/Components/Pages/Account/InvalidPasswordReset.razor b/TalentBlazor/Components/Pages/Account/InvalidPasswordReset.razor index 2856950..a58f318 100644 --- a/TalentBlazor/Components/Pages/Account/InvalidPasswordReset.razor +++ b/TalentBlazor/Components/Pages/Account/InvalidPasswordReset.razor @@ -2,8 +2,12 @@ Invalid password reset -

Invalid password reset

+
-

- The password reset link is invalid. -

+ Invalid password reset + +

+ The password reset link is invalid. +

+ +
diff --git a/TalentBlazor/Components/Pages/Account/InvalidUser.razor b/TalentBlazor/Components/Pages/Account/InvalidUser.razor index c2a9e31..9830212 100644 --- a/TalentBlazor/Components/Pages/Account/InvalidUser.razor +++ b/TalentBlazor/Components/Pages/Account/InvalidUser.razor @@ -2,8 +2,12 @@ Invalid user -

Invalid user

+
+ + Invalid user + +
+ +
-
-
diff --git a/TalentBlazor/Components/Pages/Account/Lockout.razor b/TalentBlazor/Components/Pages/Account/Lockout.razor index 5f51d34..1542240 100644 --- a/TalentBlazor/Components/Pages/Account/Lockout.razor +++ b/TalentBlazor/Components/Pages/Account/Lockout.razor @@ -2,7 +2,12 @@ Locked out -
-

Locked out

-

This account has been locked out, please try again later.

-
+
+ +
+ Locked out +

This account has been locked out, please try again later.

+
+ +
+ diff --git a/TalentBlazor/Components/Pages/Account/Login.razor b/TalentBlazor/Components/Pages/Account/Login.razor index d9d5262..bcdfe0a 100644 --- a/TalentBlazor/Components/Pages/Account/Login.razor +++ b/TalentBlazor/Components/Pages/Account/Login.razor @@ -1,4 +1,4 @@ -@page "/Account/Login" +@page "/Account/Login" @using System.ComponentModel.DataAnnotations @using System.Text @@ -17,52 +17,50 @@
-

- Use a local account to log in. -

- + Use a local account to log in. +
- +
- +
- +
- +
- +
- +
- + Log in

- Forgot your password? + Forgot your password?

- { ["ReturnUrl"] = ReturnUrl }))">Register as a new user + { ["ReturnUrl"] = ReturnUrl }))">Register as a new user

- Resend email confirmation + Resend email confirmation

@@ -71,7 +69,7 @@
-

Use another service to log in.

+ Use another service to log in.
diff --git a/TalentBlazor/Components/Pages/Account/LoginWith2fa.razor b/TalentBlazor/Components/Pages/Account/LoginWith2fa.razor index 7efb393..749d13c 100644 --- a/TalentBlazor/Components/Pages/Account/LoginWith2fa.razor +++ b/TalentBlazor/Components/Pages/Account/LoginWith2fa.razor @@ -1,4 +1,4 @@ -@page "/Account/LoginWith2fa" +@page "/Account/LoginWith2fa" @using System.ComponentModel.DataAnnotations @using Microsoft.AspNetCore.Identity @@ -13,7 +13,7 @@ Two-factor authentication
-

Two-factor authentication

+ Two-factor authentication

Your login is protected with an authenticator app. Enter your authenticator code below.

@@ -22,27 +22,27 @@ - +
- +
- +
- +
- +
- + Log in
@@ -51,7 +51,7 @@

Don't have access to your authenticator device? You can - log in with a recovery code. + log in with a recovery code.

@code { diff --git a/TalentBlazor/Components/Pages/Account/LoginWithRecoveryCode.razor b/TalentBlazor/Components/Pages/Account/LoginWithRecoveryCode.razor index 5988fe7..70a48e6 100644 --- a/TalentBlazor/Components/Pages/Account/LoginWithRecoveryCode.razor +++ b/TalentBlazor/Components/Pages/Account/LoginWithRecoveryCode.razor @@ -1,4 +1,4 @@ -@page "/Account/LoginWithRecoveryCode" +@page "/Account/LoginWithRecoveryCode" @using System.ComponentModel.DataAnnotations @using Microsoft.AspNetCore.Identity @@ -13,9 +13,9 @@ Recovery code verification -

Recovery code verification

+
+ Recovery code verification -

You have requested to log in with a recovery code. This login will not be remembered until you provide @@ -25,17 +25,17 @@

- +
- +
- +
- +
- + Log in
diff --git a/TalentBlazor/Components/Pages/Account/Logout.razor b/TalentBlazor/Components/Pages/Account/Logout.razor new file mode 100644 index 0000000..5a6cdf3 --- /dev/null +++ b/TalentBlazor/Components/Pages/Account/Logout.razor @@ -0,0 +1,10 @@ +@page "/Account/Logout" + +Signed out + +
+
+ Signed out +

You have successfully signed out.

+
+
\ No newline at end of file diff --git a/TalentBlazor/Components/Pages/Account/Manage/ChangePassword.razor b/TalentBlazor/Components/Pages/Account/Manage/ChangePassword.razor index 5df8a0d..7978a39 100644 --- a/TalentBlazor/Components/Pages/Account/Manage/ChangePassword.razor +++ b/TalentBlazor/Components/Pages/Account/Manage/ChangePassword.razor @@ -1,4 +1,4 @@ -@page "/Account/Manage/ChangePassword" +@page "/Account/Manage/ChangePassword" @using System.ComponentModel.DataAnnotations @using Microsoft.AspNetCore.Identity @@ -13,7 +13,7 @@ Change password -

Change password

+Change password
@@ -22,32 +22,32 @@
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- + Update password
diff --git a/TalentBlazor/Components/Pages/Account/Manage/DeletePersonalData.razor b/TalentBlazor/Components/Pages/Account/Manage/DeletePersonalData.razor index 4e55f50..839db00 100644 --- a/TalentBlazor/Components/Pages/Account/Manage/DeletePersonalData.razor +++ b/TalentBlazor/Components/Pages/Account/Manage/DeletePersonalData.razor @@ -1,4 +1,4 @@ -@page "/Account/Manage/DeletePersonalData" +@page "/Account/Manage/DeletePersonalData" @using System.ComponentModel.DataAnnotations @using Microsoft.AspNetCore.Identity @@ -13,7 +13,7 @@ Delete Personal Data -

Delete Personal Data

+Delete Personal Data
@@ -26,20 +26,20 @@ - +
@if (_requirePassword) {
- +
- +
- +
} - + Delete data and close my account
diff --git a/TalentBlazor/Components/Pages/Account/Manage/Disable2fa.razor b/TalentBlazor/Components/Pages/Account/Manage/Disable2fa.razor index 1ce660f..c5c91ef 100644 --- a/TalentBlazor/Components/Pages/Account/Manage/Disable2fa.razor +++ b/TalentBlazor/Components/Pages/Account/Manage/Disable2fa.razor @@ -1,4 +1,4 @@ -@page "/Account/Manage/Disable2fa" +@page "/Account/Manage/Disable2fa" @using Microsoft.AspNetCore.Identity @using TalentBlazor.Data @@ -11,7 +11,7 @@ Disable two-factor authentication (2FA) -

Disable two-factor authentication (2FA)

+Disable two-factor authentication (2FA)
@@ -29,7 +29,7 @@
- + Disable 2FA
diff --git a/TalentBlazor/Components/Pages/Account/Manage/Email.razor b/TalentBlazor/Components/Pages/Account/Manage/Email.razor index 5a8b813..d7b9746 100644 --- a/TalentBlazor/Components/Pages/Account/Manage/Email.razor +++ b/TalentBlazor/Components/Pages/Account/Manage/Email.razor @@ -1,4 +1,4 @@ -@page "/Account/Manage/Email" +@page "/Account/Manage/Email" @using System.ComponentModel.DataAnnotations @using System.Text @@ -17,7 +17,7 @@ Manage email -

Manage email

+Manage email
@@ -29,37 +29,37 @@ - +
@if (_isEmailConfirmed) {
- +
- +
} else {
- +
- +
- + Send verification email
}
- +
- +
- +
- + Change email
diff --git a/TalentBlazor/Components/Pages/Account/Manage/EnableAuthenticator.razor b/TalentBlazor/Components/Pages/Account/Manage/EnableAuthenticator.razor index bcb8507..32f070e 100644 --- a/TalentBlazor/Components/Pages/Account/Manage/EnableAuthenticator.razor +++ b/TalentBlazor/Components/Pages/Account/Manage/EnableAuthenticator.razor @@ -1,4 +1,4 @@ -@page "/Account/Manage/EnableAuthenticator" +@page "/Account/Manage/EnableAuthenticator" @using System.ComponentModel.DataAnnotations @using System.Globalization @@ -22,21 +22,21 @@ } else { -

Configure authenticator app

+ Configure authenticator app
- +

To use an authenticator app go through the following steps:

  1. Download a two-factor authenticator app like Microsoft Authenticator for - Android and - iOS or + Android and + iOS or Google Authenticator for - Android and - iOS. + Android and + iOS.

  2. @@ -45,7 +45,7 @@ else

    - Learn how to enable QR code generation. + Learn how to enable QR code generation.
    @@ -60,17 +60,17 @@ else
    - +
    - +
    - +
    - +
    - + Verify
    @@ -79,18 +79,6 @@ else
- - } @code { diff --git a/TalentBlazor/Components/Pages/Account/Manage/ExternalLogins.razor b/TalentBlazor/Components/Pages/Account/Manage/ExternalLogins.razor index 91dda82..7e0309f 100644 --- a/TalentBlazor/Components/Pages/Account/Manage/ExternalLogins.razor +++ b/TalentBlazor/Components/Pages/Account/Manage/ExternalLogins.razor @@ -1,4 +1,4 @@ -@page "/Account/Manage/ExternalLogins" +@page "/Account/Manage/ExternalLogins" @using Microsoft.AspNetCore.Authentication @using Microsoft.AspNetCore.Identity @@ -15,17 +15,17 @@ Manage your external logins
- + @if (_currentLogins?.Count > 0) { -

Registered Logins

+ Registered Logins
@foreach (var login in _currentLogins) { - +
@login.ProviderDisplayName@login.ProviderDisplayName @if (_showRemoveButton) { @@ -34,7 +34,7 @@
- + Remove
} @@ -51,8 +51,8 @@ } @if (_otherLogins?.Count > 0) { -

Add another service to log in.

-