Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: fix unregistered user name on keycloak #164

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions internal/usecase/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ func (u *UserUsecase) CreateAdmin(orgainzationId string, email string) (*domain.
Temporary: gocloak.BoolP(false),
},
},
Groups: &groups,
Groups: &groups,
FirstName: gocloak.StringP(user.Name),
})
if err != nil {
return nil, errors.Wrap(err, "creating user in keycloak failed")
Expand Down Expand Up @@ -413,8 +414,9 @@ func (u *UserUsecase) UpdateByAccountId(ctx context.Context, accountId string, u
if err != nil {
return nil, err
}
if originUser.Email == nil || *originUser.Email != user.Email {
if (originUser.Email == nil || *originUser.Email != user.Email) || (originUser.FirstName == nil || *originUser.FirstName != user.Name) {
originUser.Email = gocloak.StringP(user.Email)
originUser.FirstName = gocloak.StringP(user.Name)
err = u.kc.UpdateUser(userInfo.GetOrganizationId(), originUser)
if err != nil {
return nil, err
Expand Down Expand Up @@ -511,8 +513,9 @@ func (u *UserUsecase) Create(ctx context.Context, user *domain.User) (*domain.Us
Temporary: gocloak.BoolP(false),
},
},
Email: gocloak.StringP(user.Email),
Groups: &groups,
Email: gocloak.StringP(user.Email),
Groups: &groups,
FirstName: gocloak.StringP(user.Name),
})
if err != nil {
if _, err := u.kc.GetUser(user.Organization.ID, user.AccountId); err == nil {
Expand Down Expand Up @@ -569,8 +572,9 @@ func (u *UserUsecase) UpdateByAccountIdByAdmin(ctx context.Context, accountId st
if err != nil {
return nil, err
}
if originUser.Email == nil || *originUser.Email != user.Email {
if (originUser.Email == nil || *originUser.Email != user.Email) || (originUser.FirstName == nil || *originUser.FirstName != user.Name) {
originUser.Email = gocloak.StringP(user.Email)
originUser.FirstName = gocloak.StringP(user.Name)
err = u.kc.UpdateUser(userInfo.GetOrganizationId(), originUser)
if err != nil {
return nil, err
Expand Down
Loading