public async Task <AppResult <User> > Authenticate(User user) { var result = await Task.Run(() => _validator.ValidateObject(user)); if (!result.IsValid) { return(AppResult <User> .Error(result)); } return(AppResult <User> .Succeed(user)); }
public async Task <AppResult <LoginViewModel> > Login(LoginViewModel login) { AppResult <LoginViewModel> result; var user = _mapper.Map <LoginViewModel, User>(login); CreateHash(user); var retorno = await _accountService.Authenticate(user); if (!retorno.ValidationResult.IsValid) { result = AppResult <LoginViewModel> .Error(retorno.ValidationResult); } else { result = AppResult <LoginViewModel> .Succeed(login); } return(result); }