Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@ public override async Task<IActionResult> OnPostAsync(string returnUrl = null)
var callbackUrl = Url.Page(
"/Account/ConfirmEmail",
pageHandler: null,
values: new { area = "Identity", userId = userId, code = code },
values: new { area = "Identity", userId = userId, code = code, returnUrl = returnUrl },
protocol: Request.Scheme);

await _emailSender.SendEmailAsync(Input.Email, "Confirm your email",
$"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>.");

if (_userManager.Options.SignIn.RequireConfirmedAccount)
{
return RedirectToPage("RegisterConfirmation", new { email = Input.Email });
return RedirectToPage("RegisterConfirmation", new { email = Input.Email, returnUrl = returnUrl });
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class RegisterConfirmationModel : PageModel
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
/// directly from your code. This API may change or be removed in future releases.
/// </summary>
public virtual Task<IActionResult> OnGetAsync(string email) => throw new NotImplementedException();
public virtual Task<IActionResult> OnGetAsync(string email, string returnUrl = null) => throw new NotImplementedException();
}

internal class RegisterConfirmationModel<TUser> : RegisterConfirmationModel where TUser : class
Expand All @@ -57,12 +57,13 @@ public RegisterConfirmationModel(UserManager<TUser> userManager, IEmailSender se
_sender = sender;
}

public override async Task<IActionResult> OnGetAsync(string email)
public override async Task<IActionResult> OnGetAsync(string email, string returnUrl = null)
{
if (email == null)
{
return RedirectToPage("/Index");
}
returnUrl = returnUrl ?? Url.Content("~/");

var user = await _userManager.FindByEmailAsync(email);
if (user == null)
Expand All @@ -81,7 +82,7 @@ public override async Task<IActionResult> OnGetAsync(string email)
EmailConfirmationUrl = Url.Page(
"/Account/ConfirmEmail",
pageHandler: null,
values: new { area = "Identity", userId = userId, code = code },
values: new { area = "Identity", userId = userId, code = code, returnUrl = returnUrl },
protocol: Request.Scheme);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ public override async Task<IActionResult> OnPostAsync(string returnUrl = null)
var callbackUrl = Url.Page(
"/Account/ConfirmEmail",
pageHandler: null,
values: new { area = "Identity", userId = userId, code = code },
values: new { area = "Identity", userId = userId, code = code, returnUrl = returnUrl },
protocol: Request.Scheme);

await _emailSender.SendEmailAsync(Input.Email, "Confirm your email",
$"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>.");

if (_userManager.Options.SignIn.RequireConfirmedAccount)
{
return RedirectToPage("RegisterConfirmation", new { email = Input.Email });
return RedirectToPage("RegisterConfirmation", new { email = Input.Email, returnUrl = returnUrl });
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ public RegisterConfirmationModel(UserManager<TUser> userManager, IEmailSender se
_sender = sender;
}

public override async Task<IActionResult> OnGetAsync(string email)
public override async Task<IActionResult> OnGetAsync(string email, string returnUrl = null)
{
if (email == null)
{
return RedirectToPage("/Index");
}
returnUrl = returnUrl ?? Url.Content("~/");

var user = await _userManager.FindByEmailAsync(email);
if (user == null)
Expand All @@ -81,7 +82,7 @@ public override async Task<IActionResult> OnGetAsync(string email)
EmailConfirmationUrl = Url.Page(
"/Account/ConfirmEmail",
pageHandler: null,
values: new { area = "Identity", userId = userId, code = code },
values: new { area = "Identity", userId = userId, code = code, returnUrl = returnUrl },
protocol: Request.Scheme);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public async Task<RegisterConfirmation> SubmitRegisterFormWithConfirmation(strin
});

var registeredLocation = ResponseAssert.IsRedirect(registered);
Assert.Equal(RegisterConfirmation.Path + "?email="+userName, registeredLocation.ToString());
Assert.Equal(RegisterConfirmation.Path + "?email="+userName+"&returnUrl=%2F", registeredLocation.ToString());
var registerResponse = await Client.GetAsync(registeredLocation);
var register = await ResponseAssert.IsHtmlDocumentAsync(registerResponse);

Expand Down