Skip to content

Commit b0dbe28

Browse files
committed
Updates
1 parent 32ca279 commit b0dbe28

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

aspnetcore/blazor/security/webassembly/standalone-with-identity/account-confirmation-and-password-recovery.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ builder.Services.AddTransient<IEmailSender<AppUser>, EmailSender>();
142142

143143
## Configure the server project to require email confirmation
144144

145-
In the server's `Program` file, require a confirmed email address to sign in to the app.
145+
In the server project's `Program` file, require a confirmed email address to sign in to the app.
146146

147147
Locate the line that calls <xref:Microsoft.Extensions.DependencyInjection.IdentityServiceCollectionExtensions.AddIdentityCore%2A> and set the <xref:Microsoft.AspNetCore.Identity.SignInOptions.RequireConfirmedEmail> property to `true`:
148148

@@ -169,17 +169,12 @@ In the client project's `Register` component (`Components/Identity/Register.razo
169169

170170
## Update seed data code to confirm seeded accounts
171171

172-
In the server project's seed data class (`SeedData.cs`), change the code in the `InitializeAsync` method to confirm the seeded accounts so that they don't require confirmation for each test run of the solution:
172+
In the server project's seed data class (`SeedData.cs`), change the code in the `InitializeAsync` method to confirm the seeded accounts, which avoids requiring email address confirmation for each test run of the solution with one of the accounts:
173173

174174
```diff
175-
- if (user.Email is not null)
175+
- if (appUser is not null && user.RoleList is not null)
176176
- {
177-
- var appUser = await userManager.FindByEmailAsync(user.Email);
178-
-
179-
- if (appUser is not null && user.RoleList is not null)
180-
- {
181-
- await userManager.AddToRolesAsync(appUser, user.RoleList);
182-
- }
177+
- await userManager.AddToRolesAsync(appUser, user.RoleList);
183178
- }
184179
+ if (appUser is not null)
185180
+ {
@@ -195,10 +190,10 @@ In the server project's seed data class (`SeedData.cs`), change the code in the
195190

196191
## Enable account confirmation after a site has users
197192

198-
Enabling account confirmation on a site with users locks out all the existing users. Existing users are locked out because their accounts aren't confirmed. To work around existing user lockout, use one of the following approaches:
193+
Enabling account confirmation on a site with users locks out all the existing users. Existing users are locked out because their accounts aren't confirmed. Use one of the following approaches, which are beyond the scope of this article:
199194

200195
* Update the database to mark all existing users as confirmed.
201-
* Confirm existing users. For example, batch-send emails with confirmation links.
196+
* Batch-send emails with confirmation links to all existing users, which requires each user to confirm their own account.
202197

203198
## Password recovery
204199

0 commit comments

Comments
 (0)