mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-09 00:12:03 +01:00
Updates for redirections when user is not an admin.
This commit is contained in:
parent
26b1df4bdb
commit
54696b1112
@ -1,9 +1,5 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
// AccountSettingController handles request to /account_setting
|
// AccountSettingController handles request to /account_setting
|
||||||
type AccountSettingController struct {
|
type AccountSettingController struct {
|
||||||
BaseController
|
BaseController
|
||||||
@ -19,6 +15,6 @@ func (asc *AccountSettingController) Get() {
|
|||||||
if asc.AuthMode == "db_auth" || isAdminForLdap {
|
if asc.AuthMode == "db_auth" || isAdminForLdap {
|
||||||
asc.Forward("page_title_account_setting", "account-settings.htm")
|
asc.Forward("page_title_account_setting", "account-settings.htm")
|
||||||
} else {
|
} else {
|
||||||
asc.CustomAbort(http.StatusForbidden, "")
|
asc.Redirect("/dashboard", 302)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/vmware/harbor/src/common/dao"
|
||||||
|
"github.com/vmware/harbor/src/common/utils/log"
|
||||||
|
)
|
||||||
|
|
||||||
// AdminOptionController handles requests to /admin_option
|
// AdminOptionController handles requests to /admin_option
|
||||||
type AdminOptionController struct {
|
type AdminOptionController struct {
|
||||||
BaseController
|
BaseController
|
||||||
@ -7,5 +12,16 @@ type AdminOptionController struct {
|
|||||||
|
|
||||||
// Get renders the admin options page
|
// Get renders the admin options page
|
||||||
func (aoc *AdminOptionController) Get() {
|
func (aoc *AdminOptionController) Get() {
|
||||||
aoc.Forward("page_title_admin_option", "admin-options.htm")
|
sessionUserID, ok := aoc.GetSession("userId").(int)
|
||||||
|
if ok {
|
||||||
|
isAdmin, err := dao.IsAdminRole(sessionUserID)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Error occurred in IsAdminRole: %v", err)
|
||||||
|
}
|
||||||
|
if isAdmin {
|
||||||
|
aoc.Forward("page_title_admin_option", "admin-options.htm")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
aoc.Redirect("/dashboard", 302)
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ChangePasswordController handles request to /change_password
|
// ChangePasswordController handles request to /change_password
|
||||||
type ChangePasswordController struct {
|
type ChangePasswordController struct {
|
||||||
BaseController
|
BaseController
|
||||||
@ -19,6 +15,6 @@ func (cpc *ChangePasswordController) Get() {
|
|||||||
if cpc.AuthMode == "db_auth" || isAdminForLdap {
|
if cpc.AuthMode == "db_auth" || isAdminForLdap {
|
||||||
cpc.Forward("page_title_change_password", "change-password.htm")
|
cpc.Forward("page_title_change_password", "change-password.htm")
|
||||||
} else {
|
} else {
|
||||||
cpc.CustomAbort(http.StatusForbidden, "")
|
cpc.Redirect("/dashboard", 302)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user