Skip to content

Commit

Permalink
Merge pull request #164 from cho4036/tks-issues-873
Browse files Browse the repository at this point in the history
bugfix: fix unregistered user name on keycloak
  • Loading branch information
intelliguy authored Oct 20, 2023
2 parents 7f09bf5 + f0e793e commit 2130b36
Showing 1 changed file with 9 additions and 5 deletions.
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

0 comments on commit 2130b36

Please sign in to comment.