Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public virtual ActionResult Index(LoginModel model)
- {
- if (ModelState.IsValid)
- {
- model.Username = model.Username.Trim();
- var loginResult = _customerRegistrationService.ValidateCustomer(model.Username, model.Password);
- switch (loginResult)
- {
- case CustomerLoginResults.Successful:
- {
- var customer = model.Username.Contains("@") ?
- _customerService.GetCustomerByEmail(model.Username) :
- _customerService.GetCustomerByUsername(model.Username);
- if (customer.IsAdmin())
- {
- _authenticationService.SignIn(customer, model.RememberMe);
- return Redirect("~/Admin");
- }
- break;
- }
- case CustomerLoginResults.CustomerNotExist:
- ModelState.AddModelError("", _localizationService.GetResource("Account.Login.WrongCredentials.CustomerNotExist"));
- break;
- case CustomerLoginResults.Deleted:
- ModelState.AddModelError("", _localizationService.GetResource("Account.Login.WrongCredentials.Deleted"));
- break;
- case CustomerLoginResults.NotActive:
- ModelState.AddModelError("", _localizationService.GetResource("Account.Login.WrongCredentials.NotActive"));
- break;
- case CustomerLoginResults.NotRegistered:
- ModelState.AddModelError("", _localizationService.GetResource("Account.Login.WrongCredentials.NotRegistered"));
- break;
- case CustomerLoginResults.LockedOut:
- ModelState.AddModelError("", _localizationService.GetResource("Account.Login.WrongCredentials.LockedOut"));
- break;
- case CustomerLoginResults.WrongPassword:
- default:
- ModelState.AddModelError("", _localizationService.GetResource("Account.Login.WrongCredentials"));
- break;
- }
- }
- return View(model);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement