User: support setting org and help flags though update function (#86535)

* User: Support setting active org through update function

* User: add support to update help flags through update function
This commit is contained in:
Karl Persson
2024-04-29 08:53:05 +02:00
committed by GitHub
parent 7077a5850e
commit c4cfee8d96
14 changed files with 179 additions and 373 deletions
@@ -120,9 +120,9 @@ func (s *OrgSync) SyncOrgRolesHook(ctx context.Context, id *authn.Identity, _ *a
if _, ok := id.OrgRoles[id.OrgID]; !ok {
if len(orgIDs) > 0 {
id.OrgID = orgIDs[0]
return s.userService.SetUsingOrg(ctx, &user.SetUsingOrgCommand{
return s.userService.Update(ctx, &user.UpdateUserCommand{
UserID: userID,
OrgID: id.OrgID,
OrgID: &id.OrgID,
})
}
}
@@ -159,8 +159,8 @@ func (s *OrgSync) SetDefaultOrgHook(ctx context.Context, currentIdentity *authn.
return
}
cmd := user.SetUsingOrgCommand{UserID: userID, OrgID: s.cfg.LoginDefaultOrgId}
if svcErr := s.userService.SetUsingOrg(ctx, &cmd); svcErr != nil {
cmd := user.UpdateUserCommand{UserID: userID, OrgID: &s.cfg.LoginDefaultOrgId}
if svcErr := s.userService.Update(ctx, &cmd); svcErr != nil {
ctxLogger.Error("Failed to set default org", "id", currentIdentity.ID, "err", svcErr)
}
}