Пример #1
0
        public ActionResult ResetLogin(UserModel.User user)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //If email is valid user email
                    if (user.IsEmailValid(user.Email))
                    {
                        var resetData = new PasswordResetInfo();
                        //Create token and write to DB
                        resetData = user.CreateKeyAndTable(user.Email);
                        if (resetData != null)
                        {
                            //If token creation successful, send email to user
                            if (user.SendResetEmail(user.Email, resetData))
                            {
                                //email success view
                                return RedirectToAction("EmailSent", "User");
                            }
                            else
                            {
                                //error view
                                return RedirectToAction("Error", "User");
                            }
                        }
                        else
                        {
                            //error view
                            return RedirectToAction("Error", "User");
                        }
                    }
                    else
                    {

                        return RedirectToAction("EmailSent", "User");
                    }
                }
                return View(user);
            }
            catch (Exception ex)
            {
                Logger.WriteErrorLog(ex);
                return View(user);
            }
        }