Merge pull request #15621 from reasonerjt/rm-error-user-ctl-get

Do not check security context in Get of user controller
This commit is contained in:
Daniel Jiang 2021-09-22 11:53:26 +08:00 committed by GitHub
commit 3f007b8c7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,7 +16,7 @@ package user
import (
"context"
"fmt"
"github.com/goharbor/harbor/src/common"
commonmodels "github.com/goharbor/harbor/src/common/models"
"github.com/goharbor/harbor/src/common/security"
@ -148,10 +148,7 @@ func (c *controller) Get(ctx context.Context, id int, opt *Option) (*models.User
if err != nil {
return nil, err
}
sctx, ok := security.FromContext(ctx)
if !ok {
return nil, fmt.Errorf("can't find security context")
}
sctx, _ := security.FromContext(ctx)
lsc, ok := sctx.(*local.SecurityContext)
if ok && lsc.User() != nil && lsc.User().UserID == id {
u.AdminRoleInAuth = lsc.User().AdminRoleInAuth