Beispiel #1
0
        public ActionResult Login(LoginModel model, string returnUrl) {
            //validate CAPTCHA

            if (ModelState.IsValid) {

                model.Username = model.Username.Trim();

                var loginResult = _userRegistrationService.ValidateUser(model.Username, model.Password);
                switch (loginResult) {
                    case UserLoginResults.Successful:
                        {
                            var user = _userService.GetUserByUsername(model.Username);

                            //sign in new customer
                            _authenticationService.SignIn(user, model.RememberMe);
                            //activity log
                            _activityLogService.InsertActivity("PublicStore.Login", _localizationService.GetResource("ActivityLog.PublicStore.Login"), user);

                            if (String.IsNullOrEmpty(returnUrl) || !Url.IsLocalUrl(returnUrl))
                                return RedirectToRoute("HomePage");

                            return Redirect(returnUrl);
                        }
                    case UserLoginResults.CustomerNotExist:
                        ModelState.AddModelError("", _localizationService.GetResource("Account.Login.WrongCredentials.CustomerNotExist"));
                        break;
                    case UserLoginResults.Deleted:
                        ModelState.AddModelError("", _localizationService.GetResource("Account.Login.WrongCredentials.Deleted"));
                        break;
                    case UserLoginResults.NotActive:
                        ModelState.AddModelError("", _localizationService.GetResource("Account.Login.WrongCredentials.NotActive"));
                        break;
                    case UserLoginResults.NotRegistered:
                        ModelState.AddModelError("", _localizationService.GetResource("Account.Login.WrongCredentials.NotRegistered"));
                        break;
                    case UserLoginResults.WrongPassword:
                    default:
                        ModelState.AddModelError("", _localizationService.GetResource("Account.Login.WrongCredentials"));
                        break;
                }
            }
            return View(model);
        }
Beispiel #2
0
 public ActionResult Login(bool? checkoutAsGuest) {
     var model = new LoginModel();
     model.CheckoutAsGuest = checkoutAsGuest.GetValueOrDefault();
     return View(model);
 }