fix: handle project not found when creating token

Closes #14242

Signed-off-by: He Weiwei <hweiwei@vmware.com>
This commit is contained in:
He Weiwei 2021-02-23 11:46:05 +00:00
parent 582476647c
commit 1601c70278

View File

@ -173,6 +173,12 @@ func (rep repositoryFilter) filter(ctx security.Context, pm promgr.ProjectManage
return err
}
if project == nil {
log.Debugf("project %s does not exist, set empty permission", projectName)
a.Actions = []string{}
return nil
}
resource := rbac.NewProjectNamespace(project.ProjectID).Resource(rbac.ResourceRepository)
scopeList := make([]string, 0)
for s := range resourceScopes(ctx, resource) {