public virtual async Task <IActionResult> OnPostAsync() { try { await AccountAppService.SendPasswordResetCodeAsync( new SendPasswordResetCodeDto { Email = Email, AppName = "MVC", ReturnUrl = ReturnUrl, ReturnUrlHash = ReturnUrlHash } ); return(RedirectToPage( "./PasswordResetLinkSent", new { returnUrl = ReturnUrl, returnUrlHash = ReturnUrlHash })); } catch (BusinessException e) { var message = GetLocalizeExceptionMessage(e); MyAlerts.Warning(message, L["OperationFailed"]); return(await OnGetAsync()); } }
public virtual async Task <IActionResult> OnPostAsync() { try { ValidateModel(); await AccountAppService.ResetPasswordAsync( new ResetPasswordDto { UserId = UserId, ResetToken = ResetToken, Password = Password } ); } catch (Exception e) { var message = GetMessageFromException(e); MyAlerts.Warning(message, L["OperationFailed"]); return(await OnGetAsync()); } //TODO: Try to automatically login! return(RedirectToPage("./ResetPasswordConfirmation", new { returnUrl = ReturnUrl, returnUrlHash = ReturnUrlHash })); }
public virtual async Task <IActionResult> OnPostAsync() { try { 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 { await RegisterLocalUserAsync(); } return(Redirect(ReturnUrl ?? "~/")); } catch (UserFriendlyException e) { var message = GetMessageFromException(e); MyAlerts.Danger(message, L["OperationFailed"]); } catch (BusinessException e) { var message = GetMessageFromException(e); MyAlerts.Warning(message, L["OperationFailed"]); } return(await OnGetAsync()); }
public virtual async Task <IActionResult> OnPostAsync() { if (!await SettingProvider.IsTrueAsync(AccountSettingNames.EnableLocalLogin)) { MyAlerts.Danger(L["LocalLoginDisabledMessage"], L["OperationFailed"]); return(await OnGetAsync()); } try { ValidateModel(); } catch (AbpValidationException e) { var message = GetMessageFromException(e); MyAlerts.Warning(message, L["OperationFailed"]); return(await OnGetAsync()); } await ReplaceEmailToUsernameOfInputIfNeeds(); var result = await SignInManager.PasswordSignInAsync( Input.UserNameOrEmailAddress, Input.Password, Input.RememberMe, true ); await IdentitySecurityLogManager.SaveAsync(new IdentitySecurityLogContext { Identity = IdentitySecurityLogIdentityConsts.Identity, Action = result.ToIdentitySecurityLogAction(), UserName = Input.UserNameOrEmailAddress }); if (result.RequiresTwoFactor) { return(await TwoFactorLoginResultAsync()); } if (result.IsLockedOut) { MyAlerts.Danger(L["UserLockedOutMessage"], L["OperationFailed"]); return(await OnGetAsync()); } if (result.IsNotAllowed) { MyAlerts.Danger(L["LoginIsNotAllowed"], L["OperationFailed"]); return(await OnGetAsync()); } if (!result.Succeeded) { MyAlerts.Warning(L["InvalidUserNameOrPassword"], L["OperationFailed"]); return(await OnGetAsync()); } //TODO: Find a way of getting user's id from the logged in user and do not query it again like that! var user = await UserManager.FindByNameAsync(Input.UserNameOrEmailAddress) ?? await UserManager.FindByEmailAsync(Input.UserNameOrEmailAddress); Debug.Assert(user != null, nameof(user) + " != null"); return(RedirectSafely(ReturnUrl, ReturnUrlHash)); }