public async Task <ActionResult> Recover(AccountRecoveryView account) { if (Service.IsLoggedIn(User)) { return(RedirectToDefault()); } if (!Validator.CanRecover(account)) { return(View(account)); } if (Service.Recover(account) is String token) { String url = Url.Action("Reset", "Auth", new { token }, Request.Scheme); await MailClient.SendAsync(account.Email !, Message.For <AccountView>("RecoveryEmailSubject"), Message.For <AccountView>("RecoveryEmailBody", url)); } Alerts.AddInfo(Message.For <AccountView>("RecoveryInformation")); return(RedirectToAction("Login")); }
public async Task <ActionResult> Recover(AccountRecoveryView account) { if (Service.IsLoggedIn(User)) { return(RedirectToDefault()); } if (!Validator.CanRecover(account)) { return(View(account)); } String token = Service.Recover(account); if (token != null) { String url = Url.Action("Reset", "Auth", new { token }, Request.Url.Scheme); await MailClient.SendAsync( account.Email, Messages.RecoveryEmailSubject, String.Format(Messages.RecoveryEmailBody, url)); } Alerts.AddInfo(Messages.RecoveryInformation); return(RedirectIfAuthorized("Login")); }
public void AddInfo_Message() { alerts.AddInfo("Message", 1); Alert actual = alerts.Single(); Assert.Equal(AlertType.Info, actual.Type); Assert.Equal("Message", actual.Message); Assert.Equal(1, actual.Timeout); Assert.Null(actual.Id); }