Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use alerts to show the exception message in the register page. #4899

Merged
merged 2 commits into from
Aug 8, 2020
Merged
Changes from all commits
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 @@ -76,25 +76,33 @@ private async Task TrySetEmailAsync()

public virtual async Task<IActionResult> OnPostAsync()
{
await CheckSelfRegistrationAsync();

if (IsExternalLogin)
try
{
var externalLoginInfo = await SignInManager.GetExternalLoginInfoAsync();
if (externalLoginInfo == null)
await CheckSelfRegistrationAsync();

if (IsExternalLogin)
{
var externalLoginInfo = await SignInManager.GetExternalLoginInfoAsync();
if (externalLoginInfo == null)
{
Logger.LogWarning("External login info is not available");
return RedirectToPage("./Login");
}

await RegisterExternalUserAsync(externalLoginInfo, Input.EmailAddress);
}
else
{
Logger.LogWarning("External login info is not available");
return RedirectToPage("./Login");
await RegisterLocalUserAsync();
}

await RegisterExternalUserAsync(externalLoginInfo, Input.EmailAddress);
return Redirect(ReturnUrl ?? "~/"); //TODO: How to ensure safety? IdentityServer requires it however it should be checked somehow!
}
else
catch (BusinessException e)
{
await RegisterLocalUserAsync();
Alerts.Danger(e.Message);
return Page();
}

return Redirect(ReturnUrl ?? "~/"); //TODO: How to ensure safety? IdentityServer requires it however it should be checked somehow!
}

protected virtual async Task RegisterLocalUserAsync()
Expand Down