From 490d087d45c584f90b8c39cc8ba4ffa5dbf29fe5 Mon Sep 17 00:00:00 2001 From: Livio Amstutz Date: Mon, 16 Aug 2021 07:05:56 +0200 Subject: [PATCH] fix: set correct username / preferred login name after idp callback (#2189) --- .../repository/eventsourcing/eventstore/auth_request.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/auth/repository/eventsourcing/eventstore/auth_request.go b/internal/auth/repository/eventsourcing/eventstore/auth_request.go index 545e4222ff..73414df761 100644 --- a/internal/auth/repository/eventsourcing/eventstore/auth_request.go +++ b/internal/auth/repository/eventsourcing/eventstore/auth_request.go @@ -592,7 +592,11 @@ func (repo *AuthRequestRepo) checkExternalUserLogin(ctx context.Context, request if err != nil { return err } - request.SetUserInfo(user.ID, user.UserName, user.PreferredLoginName, user.DisplayName, user.AvatarKey, user.ResourceOwner) + username := user.UserName + if request.RequestedOrgID == "" { + username = user.PreferredLoginName + } + request.SetUserInfo(user.ID, username, user.PreferredLoginName, user.DisplayName, user.AvatarKey, user.ResourceOwner) return nil }