[management] replace invalid user with a clear error message about mismatched logins (#4097)

This commit is contained in:
Krzysztof Nazarewski (kdn)
2025-07-03 16:36:36 +02:00
committed by GitHub
parent c4ed11d447
commit 996b8c600c
2 changed files with 8 additions and 3 deletions

View File

@@ -857,7 +857,7 @@ func (am *DefaultAccountManager) LoginPeer(ctx context.Context, login types.Peer
if login.UserID != "" {
if peer.UserID != login.UserID {
log.Warnf("user mismatch when logging in peer %s: peer user %s, login user %s ", peer.ID, peer.UserID, login.UserID)
return status.Errorf(status.Unauthenticated, "invalid user")
return status.NewPeerLoginMismatchError()
}
changed, err := am.handleUserPeer(ctx, transaction, peer, settings)
@@ -1106,7 +1106,7 @@ func checkAuth(ctx context.Context, loginUserID string, peer *nbpeer.Peer) error
}
if peer.UserID != loginUserID {
log.WithContext(ctx).Warnf("user mismatch when logging in peer %s: peer user %s, login user %s ", peer.ID, peer.UserID, loginUserID)
return status.Errorf(status.Unauthenticated, "can't login with this credentials")
return status.NewPeerLoginMismatchError()
}
return nil
}