2016-06-22 09:15:25 +02:00
|
|
|
package controllers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/vmware/harbor/dao"
|
|
|
|
"github.com/vmware/harbor/utils/log"
|
|
|
|
)
|
|
|
|
|
2016-06-22 10:36:48 +02:00
|
|
|
// AddNewController handles requests to /add_new
|
2016-06-22 09:15:25 +02:00
|
|
|
type AddNewController struct {
|
|
|
|
BaseController
|
|
|
|
}
|
|
|
|
|
2016-06-22 10:36:48 +02:00
|
|
|
// Get renders the add new page
|
2016-06-22 09:15:25 +02:00
|
|
|
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
|
2016-06-28 17:42:05 +02:00
|
|
|
anc.Forward("page_title_add_new", "sign-up.htm")
|
2016-06-22 09:15:25 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
anc.CustomAbort(http.StatusUnauthorized, "Status Unauthorized.")
|
|
|
|
}
|