0
learnabp created
We would like to automatically login in the user when they Confirm their Phone Number or Reset their Password using the forgot password feature, having the user redirected to the login screen or a confirmation screen adds confusion.
In the below code there is a task //TODO: Try to automatically login! can we please have the solution so we can use it in our SaaS product for DesertFire?
public virtual async Task<IActionResult> OnPostAsync()
{
try
{
ValidateModel();
SetNormalizeReturnUrl();
await AccountAppService.ResetPasswordAsync(
new ResetPasswordDto
{
UserId = UserId,
ResetToken = ResetToken,
Password = Password
}
);
}
catch (Exception e)
{
if (e is AbpIdentityResultException && !string.IsNullOrWhiteSpace(e.Message))
{
Alerts.Warning(GetLocalizeExceptionMessage(e));
return Page();
}
if (e is AbpValidationException)
{
return Page();
}
throw;
}
//TODO: Try to automatically login!
return RedirectToPage("./ResetPasswordConfirmation", new
{
returnUrl = NormalizeReturnUrl
});
}
Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
2 Answer(s)
-
0
hi
You can try this:
var user = await UserManager.FindByIdAsync(UserId.ToString()); if (user != null) { var isPersistent = (await HttpContext.AuthenticateAsync(IdentityConstants.ApplicationScheme))?.Properties?.IsPersistent ?? false; await SignInManager.SignOutAsync(); var additionalClaims = new List<Claim>(); await SignInManager.SignInWithClaimsAsync(user, new AuthenticationProperties { IsPersistent = isPersistent }, additionalClaims); //Or //await SignInManager.SignInAsync(user, isPersistent: true); }Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
This question has been automatically marked as stale because it has not had recent activity.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)