mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-27 19:17:47 +01:00
Check user in security context before getting the ID
This commit fix a potential nil pointer issue when trying to read User ID from security context Signed-off-by: Daniel Jiang <jiangd@vmware.com>
This commit is contained in:
parent
0a8ff4c1f9
commit
ebe5733f27
@ -113,7 +113,7 @@ func (c *controller) Get(ctx context.Context, id int, opt *Option) (*models.User
|
||||
return nil, fmt.Errorf("can't find security context")
|
||||
}
|
||||
lsc, ok := sctx.(*local.SecurityContext)
|
||||
if ok && lsc.User().UserID == id {
|
||||
if ok && lsc.User() != nil && lsc.User().UserID == id {
|
||||
u.AdminRoleInAuth = lsc.User().AdminRoleInAuth
|
||||
}
|
||||
if opt != nil && opt.WithOIDCInfo {
|
||||
|
Loading…
Reference in New Issue
Block a user