mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-23 10:45:45 +01:00
handle the no session scenario in project controller
This commit is contained in:
parent
4a603f0913
commit
418d9bc2b6
@ -13,11 +13,15 @@ type ProjectController struct {
|
||||
|
||||
// Get renders project page
|
||||
func (pc *ProjectController) Get() {
|
||||
var err error
|
||||
isSysAdmin := false
|
||||
uid := pc.GetSession("userId")
|
||||
isSysAdmin, err := dao.IsAdminRole(uid)
|
||||
if err != nil {
|
||||
log.Warningf("Error in checking Admin Role for user, id: %d, error: %v", uid, err)
|
||||
isSysAdmin = false
|
||||
if uid != nil {
|
||||
isSysAdmin, err = dao.IsAdminRole(uid)
|
||||
if err != nil {
|
||||
log.Warningf("Error in checking Admin Role for user, id: %d, error: %v", uid, err)
|
||||
isSysAdmin = false
|
||||
}
|
||||
}
|
||||
pc.Data["CanCreate"] = !config.OnlyAdminCreateProject() || isSysAdmin
|
||||
pc.Forward("page_title_project", "project.htm")
|
||||
|
Loading…
Reference in New Issue
Block a user