You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aspnetcore/blazor/security/webassembly/standalone-with-identity/account-confirmation-and-password-recovery.md
## Configure the server project to require email confirmation
144
144
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.
146
146
147
147
Locate the line that calls <xref:Microsoft.Extensions.DependencyInjection.IdentityServiceCollectionExtensions.AddIdentityCore%2A> and set the <xref:Microsoft.AspNetCore.Identity.SignInOptions.RequireConfirmedEmail> property to `true`:
148
148
@@ -169,17 +169,12 @@ In the client project's `Register` component (`Components/Identity/Register.razo
169
169
170
170
## Update seed data code to confirm seeded accounts
171
171
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:
173
173
174
174
```diff
175
-
- if (user.Email is not null)
175
+
- if (appUser is not null && user.RoleList is not null)
176
176
- {
177
-
- var appUser = await userManager.FindByEmailAsync(user.Email);
178
-
-
179
-
- if (appUser is not null && user.RoleList is not null)
@@ -195,10 +190,10 @@ In the server project's seed data class (`SeedData.cs`), change the code in the
195
190
196
191
## Enable account confirmation after a site has users
197
192
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:
199
194
200
195
* 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.
0 commit comments