public ActionResult TryToLogin(TryToLoginModel model) { var userEntity = Profile.UserService.Login(model.Email, model.Password); if (userEntity == null) { Session["trytologin"] = new UserLoginModel(Profile) { IsValidEmail = true, IsValidPassword = true, ForgotPassword = true, AccountCollection = Profile.AccountCollection }; return RedirectToAction("Login"); } return RedirectToAction("Accounts"); }
public ActionResult SendNewPassword(UserLoginModel model) { if (null == model) return View("Login"); if (model.Password.Length > 0 && model.Password.Length < 65) { var regmodel = new RegistrationModel(); regmodel.Culture = Profile.CurrentCulture; regmodel.Password = model.Password; regmodel.Email = model.Email; Profile.UserService.UpdateUserPassword(regmodel); Profile.UserService.Login(regmodel.Email, regmodel.Password); return RedirectToAction("Registration"); } return View("Login", model); }
public ActionResult RegistrateUser(RegistrationModel model) { if (!Profile.IsAuthenticated) { var emailExist = Profile.UserService.IsEmailExist(model.Email); if (model.IsEmailCorrect && model.IsPasswordCorrect && !emailExist) { if (!Profile.UserService.IsUserRegistered(model.Email, model.Password)) { model.Culture = Profile.CurrentCulture; Profile.UserService.RegistrateUser(model); Profile.UserService.Login(model.Email, model.Password); return Redirect("/Profile/Accounts"); } } else { var loginModel = new UserLoginModel(Profile); loginModel.Email = model.Email; if (!model.IsEmailCorrect) { loginModel.SignUpEmailIsIncorrect = true; } if (!model.IsPasswordCorrect) { loginModel.SignUpPasswordIsIncorrect = true; } if (emailExist) { loginModel.IsEmailExist = true; } Session["signup"] = loginModel; return RedirectToAction("Login"); } } else { var currentUser = Profile.UserService.UpdateUser(model); Profile.UserService.SignOut(); if (model.IsEmailCorrect && model.IsPasswordCorrect) { Profile.UserService.Login(model.Email, model.Password); } else { Profile.UserService.Login(currentUser); } } return RedirectToAction("Accounts"); }