@@ -57,7 +57,7 @@ public static IEndpointConventionBuilder MapIdentityApi<TUser>(this IEndpointRou
57
57
// NOTE: We cannot inject UserManager<TUser> directly because the TUser generic parameter is currently unsupported by RDG.
58
58
// https://github.com/dotnet/aspnetcore/issues/47338
59
59
routeGroup . MapPost ( "/register" , async Task < Results < Ok , ValidationProblem > >
60
- ( [ FromBody ] RegisterRequest registration , [ FromServices ] IServiceProvider sp ) =>
60
+ ( [ FromBody ] RegisterRequest registration , HttpContext context , [ FromServices ] IServiceProvider sp ) =>
61
61
{
62
62
var userManager = sp . GetRequiredService < UserManager < TUser > > ( ) ;
63
63
@@ -85,7 +85,7 @@ public static IEndpointConventionBuilder MapIdentityApi<TUser>(this IEndpointRou
85
85
return CreateValidationProblem ( result ) ;
86
86
}
87
87
88
- await SendConfirmationEmailAsync ( user , userManager , email ) ;
88
+ await SendConfirmationEmailAsync ( user , userManager , context , email ) ;
89
89
return TypedResults . Ok ( ) ;
90
90
} ) ;
91
91
@@ -194,15 +194,15 @@ await signInManager.ValidateSecurityStampAsync(refreshTicket.Principal) is not T
194
194
} ) ;
195
195
196
196
routeGroup . MapPost ( "/resendConfirmationEmail" , async Task < Ok >
197
- ( [ FromBody ] ResendEmailRequest resendRequest , [ FromServices ] IServiceProvider sp ) =>
197
+ ( [ FromBody ] ResendEmailRequest resendRequest , HttpContext context , [ FromServices ] IServiceProvider sp ) =>
198
198
{
199
199
var userManager = sp . GetRequiredService < UserManager < TUser > > ( ) ;
200
200
if ( await userManager . FindByEmailAsync ( resendRequest . Email ) is not { } user )
201
201
{
202
202
return TypedResults . Ok ( ) ;
203
203
}
204
204
205
- await SendConfirmationEmailAsync ( user , userManager , resendRequest . Email ) ;
205
+ await SendConfirmationEmailAsync ( user , userManager , context , resendRequest . Email ) ;
206
206
return TypedResults . Ok ( ) ;
207
207
} ) ;
208
208
@@ -348,7 +348,7 @@ await emailSender.SendEmailAsync(resetRequest.Email, "Reset your password",
348
348
} ) ;
349
349
350
350
accountGroup . MapPost ( "/info" , async Task < Results < Ok < InfoResponse > , ValidationProblem , NotFound > >
351
- ( ClaimsPrincipal claimsPrincipal , [ FromBody ] InfoRequest infoRequest , [ FromServices ] IServiceProvider sp ) =>
351
+ ( ClaimsPrincipal claimsPrincipal , [ FromBody ] InfoRequest infoRequest , HttpContext context , [ FromServices ] IServiceProvider sp ) =>
352
352
{
353
353
var userManager = sp . GetRequiredService < UserManager < TUser > > ( ) ;
354
354
if ( await userManager . GetUserAsync ( claimsPrincipal ) is not { } user )
@@ -382,14 +382,14 @@ await emailSender.SendEmailAsync(resetRequest.Email, "Reset your password",
382
382
383
383
if ( email != infoRequest . NewEmail )
384
384
{
385
- await SendConfirmationEmailAsync ( user , userManager , infoRequest . NewEmail , isChange : true ) ;
385
+ await SendConfirmationEmailAsync ( user , userManager , context , infoRequest . NewEmail , isChange : true ) ;
386
386
}
387
387
}
388
388
389
389
return TypedResults . Ok ( await CreateInfoResponseAsync ( user , claimsPrincipal , userManager ) ) ;
390
390
} ) ;
391
391
392
- async Task SendConfirmationEmailAsync ( TUser user , UserManager < TUser > userManager , string email , bool isChange = false )
392
+ async Task SendConfirmationEmailAsync ( TUser user , UserManager < TUser > userManager , HttpContext context , string email , bool isChange = false )
393
393
{
394
394
if ( confirmEmailEndpointName is null )
395
395
{
@@ -414,7 +414,7 @@ async Task SendConfirmationEmailAsync(TUser user, UserManager<TUser> userManager
414
414
routeValues . Add ( "changedEmail" , email ) ;
415
415
}
416
416
417
- var confirmEmailUrl = linkGenerator . GetPathByName ( confirmEmailEndpointName , routeValues )
417
+ var confirmEmailUrl = linkGenerator . GetUriByName ( context , confirmEmailEndpointName , routeValues )
418
418
?? throw new NotSupportedException ( $ "Could not find endpoint named '{ confirmEmailEndpointName } '.") ;
419
419
420
420
await emailSender . SendEmailAsync ( email , "Confirm your email" ,
0 commit comments