示例#1
0
        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"));
        }
示例#2
0
        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"));
        }
示例#3
0
        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);
        }