Skip to content

Commit

Permalink
add confirmation email test2
Browse files Browse the repository at this point in the history
  • Loading branch information
KrystianKempski committed Apr 29, 2024
1 parent 6c51cb3 commit 035bd63
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,18 @@ public async Task<IActionResult> 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);
}
//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);
//}

return Page();
}
Expand Down
4 changes: 4 additions & 0 deletions DagoniteEmpire/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using DA_DataAccess;
using Microsoft.AspNetCore.Identity.UI.Services;
using DagoniteEmpire.Helper;
using Microsoft.Extensions.Options;


var builder = WebApplication.CreateBuilder(args);
Expand Down Expand Up @@ -51,6 +52,7 @@
builder.Services.AddScoped<IDbInitializer, DbInitializer>();
builder.Services.AddScoped<ErrorHandlingMiddleware>();
builder.Services.AddTransient<IEmailSender, EmailSender>();

//builder.Services.Configure<AuthMessageSenderOptions>(builder.Configuration);

//builder.Services.Configure<DataProtectionTokenProviderOptions>(o =>
Expand Down Expand Up @@ -81,6 +83,8 @@
app.UseMiddleware<ErrorHandlingMiddleware>();
app.UseHttpsRedirection();

app.Services.CreateScope().ServiceProvider.GetRequiredService<IOptions<IdentityOptions>>().Value.SignIn.RequireConfirmedAccount = true;

app.UseStaticFiles();

app.UseRouting();
Expand Down

0 comments on commit 035bd63

Please sign in to comment.