feat(http): improve invalid login handling (#597)

* feat(http): improve invalid login handling

* fix(http): do not log password
This commit is contained in:
ze0s 2022-12-31 01:04:41 +01:00 committed by GitHub
parent 9c16c7a4a1
commit 6b1490726f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -43,7 +43,7 @@ func (s *service) Login(ctx context.Context, username, password string) (*domain
u, err := s.userSvc.FindByUsername(ctx, username)
if err != nil {
s.log.Error().Err(err).Msgf("could not find user by username: %v", username)
return nil, err
return nil, errors.Wrapf(err, "invalid login: %s", username)
}
if u == nil {
@ -58,7 +58,7 @@ func (s *service) Login(ctx context.Context, username, password string) (*domain
if !match {
s.log.Error().Msg("bad credentials")
return nil, errors.New("bad credentials")
return nil, errors.Errorf("invalid login: %s", username)
}
return u, nil