mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-02 16:49:48 +01:00
31 lines
689 B
Go
31 lines
689 B
Go
package controllers
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/vmware/harbor/dao"
|
|
"github.com/vmware/harbor/utils/log"
|
|
)
|
|
|
|
type AddNewController struct {
|
|
BaseController
|
|
}
|
|
|
|
func (anc *AddNewController) Get() {
|
|
sessionUserID := anc.GetSession("userId")
|
|
anc.Data["AddNew"] = false
|
|
if sessionUserID != nil {
|
|
isAdmin, err := dao.IsAdminRole(sessionUserID.(int))
|
|
if err != nil {
|
|
log.Errorf("Error occurred in IsAdminRole: %v", err)
|
|
anc.CustomAbort(http.StatusInternalServerError, "")
|
|
}
|
|
if isAdmin && anc.AuthMode == "db_auth" {
|
|
anc.Data["AddNew"] = true
|
|
anc.Forward("Add User", "sign-up.htm")
|
|
return
|
|
}
|
|
}
|
|
anc.CustomAbort(http.StatusUnauthorized, "Status Unauthorized.")
|
|
}
|