mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-22 23:51:27 +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
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// AccountSettingController handles request to /account_setting
|
||||
type AccountSettingController struct {
|
||||
BaseController
|
||||
@ -19,6 +15,6 @@ func (asc *AccountSettingController) Get() {
|
||||
if asc.AuthMode == "db_auth" || isAdminForLdap {
|
||||
asc.Forward("page_title_account_setting", "account-settings.htm")
|
||||
} else {
|
||||
asc.CustomAbort(http.StatusForbidden, "")
|
||||
asc.Redirect("/dashboard", 302)
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,10 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/vmware/harbor/src/common/dao"
|
||||
"github.com/vmware/harbor/src/common/utils/log"
|
||||
)
|
||||
|
||||
// AdminOptionController handles requests to /admin_option
|
||||
type AdminOptionController struct {
|
||||
BaseController
|
||||
@ -7,5 +12,16 @@ type AdminOptionController struct {
|
||||
|
||||
// Get renders the admin options page
|
||||
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
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// ChangePasswordController handles request to /change_password
|
||||
type ChangePasswordController struct {
|
||||
BaseController
|
||||
@ -19,6 +15,6 @@ func (cpc *ChangePasswordController) Get() {
|
||||
if cpc.AuthMode == "db_auth" || isAdminForLdap {
|
||||
cpc.Forward("page_title_change_password", "change-password.htm")
|
||||
} else {
|
||||
cpc.CustomAbort(http.StatusForbidden, "")
|
||||
cpc.Redirect("/dashboard", 302)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user