From 9c6032826490f7e899205569b540fd49327bd97a Mon Sep 17 00:00:00 2001 From: krystian kempski Date: Tue, 30 Apr 2024 01:54:36 +0200 Subject: [PATCH] email confirmation test3 --- .../Identity/Pages/Account/RegisterConfirmation.cshtml.cs | 2 +- DagoniteEmpire/Program.cs | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml.cs b/DagoniteEmpire/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml.cs index 37f5ed6..2cd3c1c 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml.cs +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml.cs @@ -60,7 +60,7 @@ public async Task OnGetAsync(string email, string returnUrl = nul Email = email; // Once you add a real email sender, you should remove this code that lets you confirm the account - //DisplayConfirmAccountLink = false; + DisplayConfirmAccountLink = false; //if (DisplayConfirmAccountLink) //{ // var userId = await _userManager.GetUserIdAsync(user); diff --git a/DagoniteEmpire/Program.cs b/DagoniteEmpire/Program.cs index 2a81d7d..0fa89d9 100644 --- a/DagoniteEmpire/Program.cs +++ b/DagoniteEmpire/Program.cs @@ -36,7 +36,11 @@ //options.EnableSensitiveDataLogging(); }); -builder.Services.AddIdentity().AddDefaultTokenProviders().AddDefaultUI().AddEntityFrameworkStores(); +builder.Services.AddIdentity(config => + { + config.SignIn.RequireConfirmedEmail = true; + config.SignIn.RequireConfirmedAccount = true; + }).AddDefaultTokenProviders().AddDefaultUI().AddEntityFrameworkStores(); builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); builder.Services.AddScoped(); builder.Services.AddScoped(); @@ -83,7 +87,7 @@ app.UseMiddleware(); app.UseHttpsRedirection(); -app.Services.CreateScope().ServiceProvider.GetRequiredService>().Value.SignIn.RequireConfirmedAccount = true; +//app.Services.CreateScope().ServiceProvider.GetRequiredService>().Value.SignIn.RequireConfirmedAccount = true; app.UseStaticFiles();