Turn on account confirmation for blazor server app template (#13559)

This commit is contained in:
Hao Kung 2019-09-06 16:13:14 -07:00 committed by GitHub
parent f1f615282d
commit ecb7288884
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 3 deletions

View File

@ -67,7 +67,7 @@ namespace BlazorServerWeb_CSharp
options.UseSqlite(
Configuration.GetConnectionString("DefaultConnection")));
#endif
services.AddDefaultIdentity<IdentityUser>()
services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores<ApplicationDbContext>();
#elif (OrganizationalAuth)
services.AddAuthentication(AzureADDefaults.AuthenticationScheme)

View File

@ -44,7 +44,7 @@ namespace Company.WebApplication1
Configuration.GetConnectionString("DefaultConnection")));
#endif
services.AddDefaultIdentity<ApplicationUser>()
services.AddDefaultIdentity<ApplicationUser>(options => options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores<ApplicationDbContext>();
services.AddIdentityServer()

View File

@ -44,7 +44,7 @@ namespace Company.WebApplication1
Configuration.GetConnectionString("DefaultConnection")));
#endif
services.AddDefaultIdentity<ApplicationUser>()
services.AddDefaultIdentity<ApplicationUser>(options => options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores<ApplicationDbContext>();
services.AddIdentityServer()

View File

@ -273,6 +273,23 @@ namespace Templates.Test.SpaTemplateTest
browser.FindElement(By.Name("Input.Password")).SendKeys(password);
browser.FindElement(By.Name("Input.ConfirmPassword")).SendKeys(password);
browser.FindElement(By.Id("registerSubmit")).Click();
// We will be redirected to the RegisterConfirmation
browser.Contains("/Identity/Account/RegisterConfirmation", () => browser.Url);
browser.FindElement(By.PartialLinkText("Click here to confirm your account")).Click();
// We will be redirected to the ConfirmEmail
browser.Contains("/Identity/Account/ConfirmEmail", () => browser.Url);
// Now we can login
browser.FindElement(By.PartialLinkText("Login")).Click();
browser.Exists(By.Name("Input.Email"));
browser.FindElement(By.Name("Input.Email")).SendKeys(userName);
browser.FindElement(By.Name("Input.Password")).SendKeys(password);
browser.FindElement(By.Id("login-submit")).Click();
// Need to navigate to fetch page
browser.FindElement(By.PartialLinkText("Fetch data")).Click();
}
// Can navigate to the 'fetch data' page