private User CheckUser(UserCredentials credentials) { var found = this.GetUserFromDatabase(credentials?.username, credentials?.password.EncryptPassword()); if (found != null) { return(found); } return(new User() { id = 0 }); }
public dynamic Get(UserCredentials credentials) { if (string.IsNullOrEmpty(credentials?.username) || string.IsNullOrEmpty(credentials?.password)) { throw new HttpResponseException(HttpStatusCode.Unauthorized); } var user = this.CheckUser(credentials); if (user.id != 0) { return(JwtManager.GenerateToken(user)); } throw new HttpResponseException(HttpStatusCode.Unauthorized); }