@@ -57,7 +57,7 @@ public static IEndpointConventionBuilder MapIdentityApi<TUser>(this IEndpointRou
5757 // NOTE: We cannot inject UserManager<TUser> directly because the TUser generic parameter is currently unsupported by RDG.
5858 // https://github.com/dotnet/aspnetcore/issues/47338
5959 routeGroup . MapPost ( "/register" , async Task < Results < Ok , ValidationProblem > >
60- ( [ FromBody ] RegisterRequest registration , [ FromServices ] IServiceProvider sp ) =>
60+ ( [ FromBody ] RegisterRequest registration , HttpContext context , [ FromServices ] IServiceProvider sp ) =>
6161 {
6262 var userManager = sp . GetRequiredService < UserManager < TUser > > ( ) ;
6363
@@ -85,7 +85,7 @@ public static IEndpointConventionBuilder MapIdentityApi<TUser>(this IEndpointRou
8585 return CreateValidationProblem ( result ) ;
8686 }
8787
88- await SendConfirmationEmailAsync ( user , userManager , email ) ;
88+ await SendConfirmationEmailAsync ( user , userManager , context , email ) ;
8989 return TypedResults . Ok ( ) ;
9090 } ) ;
9191
@@ -194,15 +194,15 @@ await signInManager.ValidateSecurityStampAsync(refreshTicket.Principal) is not T
194194 } ) ;
195195
196196 routeGroup . MapPost ( "/resendConfirmationEmail" , async Task < Ok >
197- ( [ FromBody ] ResendEmailRequest resendRequest , [ FromServices ] IServiceProvider sp ) =>
197+ ( [ FromBody ] ResendEmailRequest resendRequest , HttpContext context , [ FromServices ] IServiceProvider sp ) =>
198198 {
199199 var userManager = sp . GetRequiredService < UserManager < TUser > > ( ) ;
200200 if ( await userManager . FindByEmailAsync ( resendRequest . Email ) is not { } user )
201201 {
202202 return TypedResults . Ok ( ) ;
203203 }
204204
205- await SendConfirmationEmailAsync ( user , userManager , resendRequest . Email ) ;
205+ await SendConfirmationEmailAsync ( user , userManager , context , resendRequest . Email ) ;
206206 return TypedResults . Ok ( ) ;
207207 } ) ;
208208
@@ -348,7 +348,7 @@ await emailSender.SendEmailAsync(resetRequest.Email, "Reset your password",
348348 } ) ;
349349
350350 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 ) =>
352352 {
353353 var userManager = sp . GetRequiredService < UserManager < TUser > > ( ) ;
354354 if ( await userManager . GetUserAsync ( claimsPrincipal ) is not { } user )
@@ -382,14 +382,14 @@ await emailSender.SendEmailAsync(resetRequest.Email, "Reset your password",
382382
383383 if ( email != infoRequest . NewEmail )
384384 {
385- await SendConfirmationEmailAsync ( user , userManager , infoRequest . NewEmail , isChange : true ) ;
385+ await SendConfirmationEmailAsync ( user , userManager , context , infoRequest . NewEmail , isChange : true ) ;
386386 }
387387 }
388388
389389 return TypedResults . Ok ( await CreateInfoResponseAsync ( user , claimsPrincipal , userManager ) ) ;
390390 } ) ;
391391
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 )
393393 {
394394 if ( confirmEmailEndpointName is null )
395395 {
@@ -414,7 +414,7 @@ async Task SendConfirmationEmailAsync(TUser user, UserManager<TUser> userManager
414414 routeValues . Add ( "changedEmail" , email ) ;
415415 }
416416
417- var confirmEmailUrl = linkGenerator . GetPathByName ( confirmEmailEndpointName , routeValues )
417+ var confirmEmailUrl = linkGenerator . GetUriByName ( context , confirmEmailEndpointName , routeValues )
418418 ?? throw new NotSupportedException ( $ "Could not find endpoint named '{ confirmEmailEndpointName } '.") ;
419419
420420 await emailSender . SendEmailAsync ( email , "Confirm your email" ,
0 commit comments