mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-21 08:07:59 +01:00
35 lines
844 B
Go
35 lines
844 B
Go
|
package ng
|
||
|
|
||
|
import (
|
||
|
"net/http"
|
||
|
|
||
|
"github.com/vmware/harbor/dao"
|
||
|
"github.com/vmware/harbor/models"
|
||
|
"github.com/vmware/harbor/utils/log"
|
||
|
)
|
||
|
|
||
|
type NavigationDetailController struct {
|
||
|
BaseController
|
||
|
}
|
||
|
|
||
|
func (ndc *NavigationDetailController) Get() {
|
||
|
sessionUserID := ndc.GetSession("userId")
|
||
|
var isAdmin int
|
||
|
if sessionUserID != nil {
|
||
|
userID := sessionUserID.(int)
|
||
|
u, err := dao.GetUser(models.User{UserID: userID})
|
||
|
if err != nil {
|
||
|
log.Errorf("Error occurred in GetUser, error: %v", err)
|
||
|
ndc.CustomAbort(http.StatusInternalServerError, "Internal error.")
|
||
|
}
|
||
|
if u == nil {
|
||
|
log.Warningf("User was deleted already, user id: %d, canceling request.", userID)
|
||
|
ndc.CustomAbort(http.StatusUnauthorized, "")
|
||
|
}
|
||
|
isAdmin = u.HasAdminRole
|
||
|
}
|
||
|
ndc.Data["IsAdmin"] = isAdmin
|
||
|
ndc.TplName = "ng/navigation-detail.htm"
|
||
|
ndc.Render()
|
||
|
}
|