handle the no session scenario in project controller

This commit is contained in:
Tan Jiang 2016-11-18 19:38:36 +08:00
parent 4a603f0913
commit 418d9bc2b6

View File

@ -13,12 +13,16 @@ 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 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")
}