public async Task <CommandResponse <User> > Authenticate(string username, string password) { var user = (await _mediator.Send(GetUserByQuery.New(x => x.Username == username))).FirstOrDefault(); if (user is null || !PasswordHelper.VerifyPasswordHash(password, user.PasswordHash, user.PasswordSalt)) { return(CommandResponse <User> .FromFailure(AuthentificationServiceException.AuthentificationFailed)); } return(CommandResponse <User> .FromSuccess(user)); }