From 74b120fd619d9e91898b55bc8876cd8900c396f4 Mon Sep 17 00:00:00 2001 From: krystian kempski Date: Tue, 30 Apr 2024 02:29:23 +0200 Subject: [PATCH] email confirmation test4 --- .../Account/RegisterConfirmation.cshtml.cs | 22 +++++++++---------- DagoniteEmpire/Program.cs | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml.cs b/DagoniteEmpire/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml.cs index 2cd3c1c..b9ad89c 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml.cs +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml.cs @@ -61,17 +61,17 @@ 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; - //if (DisplayConfirmAccountLink) - //{ - // var userId = await _userManager.GetUserIdAsync(user); - // var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); - // code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); - // EmailConfirmationUrl = Url.Page( - // "/Account/ConfirmEmail", - // pageHandler: null, - // values: new { area = "Identity", userId = userId, code = code, returnUrl = returnUrl }, - // protocol: Request.Scheme); - //} + if (DisplayConfirmAccountLink) + { + var userId = await _userManager.GetUserIdAsync(user); + var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); + code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); + EmailConfirmationUrl = Url.Page( + "/Account/ConfirmEmail", + pageHandler: null, + values: new { area = "Identity", userId = userId, code = code, returnUrl = returnUrl }, + protocol: Request.Scheme); + } return Page(); } diff --git a/DagoniteEmpire/Program.cs b/DagoniteEmpire/Program.cs index 0fa89d9..42b75ed 100644 --- a/DagoniteEmpire/Program.cs +++ b/DagoniteEmpire/Program.cs @@ -38,7 +38,7 @@ builder.Services.AddIdentity(config => { - config.SignIn.RequireConfirmedEmail = true; + // config.SignIn.RequireConfirmedEmail = true; config.SignIn.RequireConfirmedAccount = true; }).AddDefaultTokenProviders().AddDefaultUI().AddEntityFrameworkStores(); builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());