File tree Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -301,7 +301,35 @@ func (p *portalProxy) buildCNSIList(c echo.Context) ([]*interfaces.CNSIRecord, e
301
301
}
302
302
303
303
if p .GetConfig ().UserEndpointsEnabled != config .UserEndpointsConfigEnum .AdminOnly {
304
- return p .ListAdminEndpoints (userID .(string ))
304
+ // remove existing system endpoint if user endpoint already exists and sessionuser not admin
305
+ unfilteredList , err := p .ListAdminEndpoints (userID .(string ))
306
+ if err != nil {
307
+ return unfilteredList , err
308
+ }
309
+
310
+ filteredList := []* interfaces.CNSIRecord {}
311
+
312
+ for _ , endpoint := range unfilteredList {
313
+ duplicateSystemEndpoint := false
314
+ duplicateEndpointIndex := - 1
315
+
316
+ for i := 0 ; i < len (filteredList ); i ++ {
317
+ if filteredList [i ].APIEndpoint .String () == endpoint .APIEndpoint .String () {
318
+ duplicateSystemEndpoint = len (filteredList [i ].Creator ) != 0
319
+ duplicateEndpointIndex = i
320
+ }
321
+ }
322
+
323
+ if duplicateEndpointIndex != - 1 && ! u .Admin {
324
+ if duplicateSystemEndpoint {
325
+ filteredList [duplicateEndpointIndex ] = endpoint
326
+ }
327
+ } else {
328
+ filteredList = append (filteredList , endpoint )
329
+ }
330
+ }
331
+
332
+ return filteredList , err
305
333
}
306
334
}
307
335
return p .ListAdminEndpoints ("" )
You can’t perform that action at this time.
0 commit comments