コード例 #1
0
        public ActionResult Login(AuthenticationModel model)
        {
            var operationResult = accountService.Authenticate(model);
            if (operationResult.IsValid)
            {
                FormsAuthentication.SetAuthCookie(model.UserName, true);
                return RedirectToAction("Index", "Character");
            }

            operationResult.ToModelErrors(ModelState);
            return View(model);
        }
コード例 #2
0
        ValidationResult IAccountService.Authenticate(AuthenticationModel model)
        {
            var validaitonErrors = validationService.Validate(model);
            if (validaitonErrors.Any())
            {
                return new ValidationResult(validaitonErrors);
            }

            var account = accountDao.Load(model.UserName);
            if (account == null)
            {
                return new ValidationResult("UserName", validationMessageProvider.Get(ValidationMessageKeys.Authentication_Invalid_Credentials));
            }

            if (!encryptionService.IsValidPassword(model.Password, account.Password))
            {
                return new ValidationResult("UserName", validationMessageProvider.Get(ValidationMessageKeys.Authentication_Invalid_Credentials));
            }

            return ValidationResult.Ok;
        }
コード例 #3
0
 ICollection<ValidationError> IValidationService.Validate(AuthenticationModel model)
 {
     return authenticationValidator.Validate(model).Errors.ToValidationResultItem();
 }