using System.Web; using Socialize.Infrastructure.Configuration; using Socialize.Infrastructure.Emailer.Contracts; using Socialize.Modules.Identity.Data; using Microsoft.Extensions.Options; namespace Socialize.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 Socialize!

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}

"""); } }