MCPcopy Index your code
hub / github.com/rilldata/rill / UpdateOrganizationMemberUserRole

Method UpdateOrganizationMemberUserRole

admin/user.go:104–127  ·  view source on GitHub ↗

UpdateOrganizationMemberUserRole updates the role of a user in an organization. It transactionally also updates the user's membership of relevant managed usergroups in the org.

(ctx context.Context, orgID, userID, roleID string)

Source from the content-addressed store, hash-verified

102// UpdateOrganizationMemberUserRole updates the role of a user in an organization.
103// It transactionally also updates the user's membership of relevant managed usergroups in the org.
104func (s *Service) UpdateOrganizationMemberUserRole(ctx context.Context, orgID, userID, roleID string) error {
105 ctx, tx, err := s.DB.NewTx(ctx, true)
106 if err != nil {
107 return err
108 }
109 defer func() { _ = tx.Rollback() }()
110
111 err = s.DB.UpdateOrganizationMemberUserRole(ctx, orgID, userID, roleID)
112 if err != nil {
113 return err
114 }
115
116 err = s.DB.DeleteManagedUsergroupsMemberUser(ctx, orgID, userID)
117 if err != nil {
118 return err
119 }
120
121 err = s.DB.InsertManagedUsergroupsMemberUser(ctx, orgID, userID, roleID)
122 if err != nil {
123 return err
124 }
125
126 return tx.Commit()
127}
128
129// CreateOrUpdateUser creates or updates a user with the given email, name, and photo URL.
130// If the user doesn't exist, it creates a new user and simultaneously adds them to any orgs and projects they have been invited to.

Callers

nothing calls this directly

Calls 6

NewTxMethod · 0.65
RollbackMethod · 0.65
CommitMethod · 0.65

Tested by

no test coverage detected