You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
context.Request.Headers.Append("tenant", tenant);
return Task.FromResult(userService.ConfirmEmailAsync(userId, code, tenant, cancellationToken));
})
.WithName(nameof(GetConirmEmailEndpoint))
.WithSummary("Confirm email")
.WithDescription("Confirm email address for a user.")
.AllowAnonymous();
}
}`
Service
` public async Task ConfirmEmailAsync(string userId, string code, string tenant, CancellationToken cancellationToken)
{
EnsureValidTenant();
var user = await userManager.Users
.Where(u => u.Id == userId )
.FirstOrDefaultAsync(cancellationToken) ?? throw new NotFoundException($"User with Id: {userId} not found!");
if (user!.EmailConfirmed) return $"Account: {userId} already confirmed with E-Mail {user.Email} ";
code = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(code));
var result = await userManager.ConfirmEmailAsync(user, code);
return result.Succeeded
? $"Account Confirmed for E-Mail {user.Email}. You can now use the /api/tokens endpoint to generate JWT."
: throw new InternalServerException($"An error occurred while confirming {user.Email}");
}`
The text was updated successfully, but these errors were encountered:
Hi All,
I try to migrate this feature from v1, but unsucessfully. I always catch the error with usermanager... Please support me !!!
Flow is my code:
Endpoint:
` public static class GetConirmEmailEndpoint
{
internal static RouteHandlerBuilder MapGetCornfirmEmailEndpoint(this IEndpointRouteBuilder endpoints)
{
return endpoints.MapGet("/confirm-email", async (
[FromQuery] string userId,
[FromQuery] string code,
[FromQuery] string tenant,
HttpContext context,
ITenantService tenantService,
IUserService userService,
CancellationToken cancellationToken) =>
{
TenantDetail tenantDetail = await tenantService.GetByIdAsync(tenant) ?? throw new NotFoundException($"Tenant: {tenant} not found");
var tenantInfo = tenantDetail.Adapt();
context.SetTenantInfo(tenantInfo, true);
}`
Service
` public async Task ConfirmEmailAsync(string userId, string code, string tenant, CancellationToken cancellationToken)
{
EnsureValidTenant();
}`
The text was updated successfully, but these errors were encountered: