public Response <UserModelToken> Authenticate(string username, string password) { var response = new Response <UserModelToken>(); if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) { response.Message = "Parámetros no pueden ser vacios."; return(response); } try { var user = _userModelDomain.Authenticate(username, password); response.Data = _mapper.Map <UserModelToken>(user); response.IsSuccess = true; response.Message = "Autenticación Exitosa!!!"; } catch (InvalidOperationException) { response.IsSuccess = true; response.Message = "Usuario no existe"; } catch (Exception e) { response.Message = e.Message; } return(response); }
public Response <UserDTO> Authenticate(string username, string password) { var response = new Response <UserDTO>(); if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) { response.Message = "Please insert all params"; return(response); } try { var user = _userDomain.Authenticate(username, password); response.Data = _mapper.Map <UserDTO>(user); response.IsSuccess = true; response.Message = "Authenticated"; } catch (InvalidOperationException) { response.IsSuccess = true; response.Message = "User does not exist"; } catch (Exception e) { response.Message = e.Message; } return(response); }
public IActionResult SignIn(LoginViewModel login) { var id = _userDomain.Authenticate(login); if (id == null) { return(UnprocessableEntity()); } return(GenerateUserInfo((int)id)); }