Merge pull request #14910 from reasonerjt/fix-oidc-callback-nil-pointer

Check user in security context before getting the ID
This commit is contained in:
Daniel Jiang 2021-05-18 23:35:46 +08:00 committed by GitHub
commit 4492e47e89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -37,7 +37,7 @@ jobs:
- name: setup Docker - name: setup Docker
uses: docker-practice/actions-setup-docker@0.0.1 uses: docker-practice/actions-setup-docker@0.0.1
with: with:
docker_version: 18.09 docker_version: 20.04
docker_channel: stable docker_channel: stable
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:

View File

@ -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") return nil, fmt.Errorf("can't find security context")
} }
lsc, ok := sctx.(*local.SecurityContext) 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 u.AdminRoleInAuth = lsc.User().AdminRoleInAuth
} }
if opt != nil && opt.WithOIDCInfo { if opt != nil && opt.WithOIDCInfo {