Ejemplo n.º 1
0
        public async Task <ActionResult> FbPsw(FindBackPasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            try
            {
                SecurityVerify.Verify <FbPswEmailVerification>(model.Email.Replace("@", "_"), null, model.Code);
            }
            catch (ApplicationException ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(View(model));
            }
            catch (Exception)
            {
                ModelState.AddModelError("", GeneralResource.SaveFailed);
                return(View(model));
            }
            var accountComponent = new AccountComponent();
            var account          = await accountComponent.GetAccountByEmailAsync(model.Email);

            if (account == null)
            {
                ModelState.AddModelError("", AccountFbPsw.EmailNotBind);
                return(View(model));
            }
            if (account.Status != (byte)AccountStatus.Active)
            {
                ViewBag.PasswordHasSet = -1;
                return(View(model));
            }
            await accountComponent.ResetPasswordAsync(account.Id, PasswordHasher.HashPassword(model.Password));

            ViewBag.PasswordHasSet = 1;
            return(View(model));
        }