public UserViewModel Login(LoginUiCommand command) { if (IsNullOrEmpty(command.Account) || IsNullOrEmpty(command.Password)) { throw new LogicException(ErrorMessage.UserLoginNull); } var currentUser = _systemUserRepository.GetAll(x => x.LoginName == command.Account).SingleOrDefault(); if (currentUser == null) { throw new LogicException(ErrorMessage.UserIsNotExist); } if (!PasswordHasher.ValidateHash(command.Password, currentUser.Password)) { throw new LogicException(ErrorMessage.UserLoginFault); } currentUser.LastLoginDate = _currentTimeProvider.CurrentTime(); _systemUserRepository.Edit(currentUser); var user = currentUser.User.ToLoginViewModel(); return(user); }
public UserViewModel Login([FromBody] LoginUiCommand command) { return(_loginLogic.Login(command)); }