mirror of
https://github.com/goharbor/harbor
synced 2025-04-19 22:57:59 +00:00
Updates for blocking account settings in LDAP auth mode.
This commit is contained in:
parent
ce7b556e84
commit
45803b53e1
|
@ -1,5 +1,9 @@
|
||||||
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
|
||||||
|
@ -7,5 +11,8 @@ type AccountSettingController struct {
|
||||||
|
|
||||||
// Get renders the account settings page
|
// Get renders the account settings page
|
||||||
func (asc *AccountSettingController) Get() {
|
func (asc *AccountSettingController) Get() {
|
||||||
|
if asc.AuthMode != "db_auth" {
|
||||||
|
asc.CustomAbort(http.StatusForbidden, "")
|
||||||
|
}
|
||||||
asc.Forward("page_title_account_setting", "account-settings.htm")
|
asc.Forward("page_title_account_setting", "account-settings.htm")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
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
|
||||||
|
@ -7,5 +11,8 @@ type ChangePasswordController struct {
|
||||||
|
|
||||||
// Get renders the change password page
|
// Get renders the change password page
|
||||||
func (asc *ChangePasswordController) Get() {
|
func (asc *ChangePasswordController) Get() {
|
||||||
|
if asc.AuthMode != "db_auth" {
|
||||||
|
asc.CustomAbort(http.StatusForbidden, "")
|
||||||
|
}
|
||||||
asc.Forward("page_title_change_password", "change-password.htm")
|
asc.Forward("page_title_change_password", "change-password.htm")
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ func (omc *OptionalMenuController) Get() {
|
||||||
|
|
||||||
var hasLoggedIn bool
|
var hasLoggedIn bool
|
||||||
var allowAddNew bool
|
var allowAddNew bool
|
||||||
|
var allowSettingAccount bool
|
||||||
|
|
||||||
if sessionUserID != nil {
|
if sessionUserID != nil {
|
||||||
hasLoggedIn = true
|
hasLoggedIn = true
|
||||||
|
@ -34,6 +35,10 @@ func (omc *OptionalMenuController) Get() {
|
||||||
}
|
}
|
||||||
omc.Data["Username"] = u.Username
|
omc.Data["Username"] = u.Username
|
||||||
|
|
||||||
|
if omc.AuthMode == "db_auth" {
|
||||||
|
allowSettingAccount = true
|
||||||
|
}
|
||||||
|
|
||||||
isAdmin, err := dao.IsAdminRole(sessionUserID.(int))
|
isAdmin, err := dao.IsAdminRole(sessionUserID.(int))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Error occurred in IsAdminRole: %v", err)
|
log.Errorf("Error occurred in IsAdminRole: %v", err)
|
||||||
|
@ -45,6 +50,7 @@ func (omc *OptionalMenuController) Get() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
omc.Data["AddNew"] = allowAddNew
|
omc.Data["AddNew"] = allowAddNew
|
||||||
|
omc.Data["SettingAccount"] = allowSettingAccount
|
||||||
omc.Data["HasLoggedIn"] = hasLoggedIn
|
omc.Data["HasLoggedIn"] = hasLoggedIn
|
||||||
omc.TplName = "optional-menu.htm"
|
omc.TplName = "optional-menu.htm"
|
||||||
omc.Render()
|
omc.Render()
|
||||||
|
|
|
@ -12,7 +12,7 @@ type SignUpController struct {
|
||||||
// Get renders sign up page
|
// Get renders sign up page
|
||||||
func (suc *SignUpController) Get() {
|
func (suc *SignUpController) Get() {
|
||||||
if suc.AuthMode != "db_auth" || !suc.SelfRegistration {
|
if suc.AuthMode != "db_auth" || !suc.SelfRegistration {
|
||||||
suc.CustomAbort(http.StatusUnauthorized, "Status unauthorized.")
|
suc.CustomAbort(http.StatusForbidden, "")
|
||||||
}
|
}
|
||||||
suc.Data["AddNew"] = false
|
suc.Data["AddNew"] = false
|
||||||
suc.Forward("page_title_sign_up", "sign-up.htm")
|
suc.Forward("page_title_sign_up", "sign-up.htm")
|
||||||
|
|
|
@ -21,7 +21,9 @@
|
||||||
{{ if eq .AddNew true }}
|
{{ if eq .AddNew true }}
|
||||||
<li><a href="/add_new"><span class="glyphicon glyphicon-plus"></span> // 'add_new_title' | tr //</a></li>
|
<li><a href="/add_new"><span class="glyphicon glyphicon-plus"></span> // 'add_new_title' | tr //</a></li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ if eq .SettingAccount true }}
|
||||||
<li><a href="/account_setting"><span class="glyphicon glyphicon-pencil"></span> // 'account_setting' | tr //</a></li>
|
<li><a href="/account_setting"><span class="glyphicon glyphicon-pencil"></span> // 'account_setting' | tr //</a></li>
|
||||||
|
{{ end }}
|
||||||
<li class="dropdown-submenu">
|
<li class="dropdown-submenu">
|
||||||
<a tabindex="-1" href="#"><span class="glyphicon glyphicon-globe"></span> //vm.languageName//</a>
|
<a tabindex="-1" href="#"><span class="glyphicon glyphicon-globe"></span> //vm.languageName//</a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
|
|
Loading…
Reference in New Issue
Block a user