using System.Web; using Hutopy.Infrastructure.Configuration; using Hutopy.Infrastructure.Emailer.Contracts; using Hutopy.Modules.Identity.Data; using Microsoft.Extensions.Options; namespace Hutopy.Modules.Identity.Services; [PublicAPI] public sealed class EmailVerificationService( IOptionsSnapshot options, UserManager userManager, IEmailSender emailSender) { public async Task SendVerificationEmailAsync( User user) { // Generate email confirmation token string token = await userManager.GenerateEmailConfirmationTokenAsync(user); string encodedToken = HttpUtility.UrlEncode(token); string verificationLink = $"{options.Value.FrontendBaseUrl}/verify-email?userId={user.Id}&token={encodedToken}"; // Send verification email await emailSender.SendEmailAsync( user.Email!, "Verify your email address", $"""

Welcome to Hutopy!

Please verify your email address by clicking the button below:

Verify Email Address

If you did not request this, please ignore this email.

If the button doesn't work, you can copy and paste this link into your browser:
{verificationLink}

"""); } }