Пример #1
0
        public LoginResponse Login(LoginFormViewModel model)
        {
            try
            {
                var user = _userRepository.GetUserBy(x => x.UserEmail == model.UserEmail && x.IsActive == true);
                if (user != null && _hashingService.Compare(user.UserPassword, model.UserPassword))
                {
                    FormsAuthentication.SetAuthCookie(user.UserEmail, createPersistentCookie: false);

                    return(new LoginResponse()
                    {
                        IsError = false,
                        Message = "Login.Submit.Success",
                    });
                }
            }
            catch (Exception exception)
            {
                Log.Error("Error during login", exception);
            }
            return(new LoginResponse()
            {
                IsError = true,
                Message = "Login.Submit.Failure",
            });
        }