@@ -93,15 +93,15 @@ func (api *API) patchGroupIDPSyncSettings(rw http.ResponseWriter, r *http.Reques
93
93
return
94
94
}
95
95
96
- existing , err := api .IDPSync .GroupSyncSettings (ctx , org .ID , api .Database )
96
+ //nolint:gocritic // Requires system context to update runtime config
97
+ sysCtx := dbauthz .AsSystemRestricted (ctx )
98
+ existing , err := api .IDPSync .GroupSyncSettings (sysCtx , org .ID , api .Database )
97
99
if err != nil {
98
100
httpapi .InternalServerError (rw , err )
99
101
return
100
102
}
101
103
aReq .Old = * existing
102
104
103
- //nolint:gocritic // Requires system context to update runtime config
104
- sysCtx := dbauthz .AsSystemRestricted (ctx )
105
105
err = api .IDPSync .UpdateGroupSettings (sysCtx , org .ID , api .Database , idpsync.GroupSyncSettings {
106
106
Field : req .Field ,
107
107
Mapping : req .Mapping ,
@@ -192,15 +192,15 @@ func (api *API) patchRoleIDPSyncSettings(rw http.ResponseWriter, r *http.Request
192
192
return
193
193
}
194
194
195
- existing , err := api .IDPSync .RoleSyncSettings (ctx , org .ID , api .Database )
195
+ //nolint:gocritic // Requires system context to update runtime config
196
+ sysCtx := dbauthz .AsSystemRestricted (ctx )
197
+ existing , err := api .IDPSync .RoleSyncSettings (sysCtx , org .ID , api .Database )
196
198
if err != nil {
197
199
httpapi .InternalServerError (rw , err )
198
200
return
199
201
}
200
202
aReq .Old = * existing
201
203
202
- //nolint:gocritic // Requires system context to update runtime config
203
- sysCtx := dbauthz .AsSystemRestricted (ctx )
204
204
err = api .IDPSync .UpdateRoleSettings (sysCtx , org .ID , api .Database , idpsync.RoleSyncSettings {
205
205
Field : req .Field ,
206
206
Mapping : req .Mapping ,
@@ -278,20 +278,20 @@ func (api *API) patchOrganizationIDPSyncSettings(rw http.ResponseWriter, r *http
278
278
return
279
279
}
280
280
281
- existing , err := api .IDPSync .OrganizationSyncSettings (ctx , api .Database )
282
- if err != nil {
283
- httpapi .InternalServerError (rw , err )
284
- return
285
- }
286
- aReq .Old = * existing
287
-
288
281
var req codersdk.OrganizationSyncSettings
289
282
if ! httpapi .Read (ctx , rw , r , & req ) {
290
283
return
291
284
}
292
285
293
286
//nolint:gocritic // Requires system context to update runtime config
294
287
sysCtx := dbauthz .AsSystemRestricted (ctx )
288
+ existing , err := api .IDPSync .OrganizationSyncSettings (sysCtx , api .Database )
289
+ if err != nil {
290
+ httpapi .InternalServerError (rw , err )
291
+ return
292
+ }
293
+ aReq .Old = * existing
294
+
295
295
err = api .IDPSync .UpdateOrganizationSettings (sysCtx , api .Database , idpsync.OrganizationSyncSettings {
296
296
Field : req .Field ,
297
297
// We do not check if the mappings point to actual organizations.
0 commit comments