mirror of
https://github.com/goharbor/harbor
synced 2025-05-07 14:46:32 +00:00
updates self-registration on checking with ldap_auth mode.
This commit is contained in:
parent
21430b0ebb
commit
0a0ee13d3f
@ -34,15 +34,14 @@ type RegisterController struct {
|
|||||||
// Get renders the Sign In page, it only works if the auth mode is set to db_auth
|
// Get renders the Sign In page, it only works if the auth mode is set to db_auth
|
||||||
func (rc *RegisterController) Get() {
|
func (rc *RegisterController) Get() {
|
||||||
|
|
||||||
|
if enableAddUserByAdmin && !isAdminLoginedUser {
|
||||||
|
log.Error("Self registration can only be used by admin user.\n")
|
||||||
|
rc.Redirect("/signIn", http.StatusFound)
|
||||||
|
}
|
||||||
|
|
||||||
pageTitleKey := "page_title_registration"
|
pageTitleKey := "page_title_registration"
|
||||||
|
|
||||||
if enableAddUserByAdmin {
|
if isAdminLoginedUser {
|
||||||
|
|
||||||
if !isAdminLoginedUser {
|
|
||||||
log.Error("Self registration can only be used by admin user.\n")
|
|
||||||
rc.Redirect("/signIn", http.StatusFound)
|
|
||||||
}
|
|
||||||
|
|
||||||
pageTitleKey = "page_title_add_user"
|
pageTitleKey = "page_title_add_user"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,6 +56,11 @@ func (rc *RegisterController) Get() {
|
|||||||
// SignUp insert data into DB based on data in form.
|
// SignUp insert data into DB based on data in form.
|
||||||
func (rc *CommonController) SignUp() {
|
func (rc *CommonController) SignUp() {
|
||||||
|
|
||||||
|
authMode := os.Getenv("AUTH_MODE")
|
||||||
|
if !(authMode == "" || authMode == "db_auth") {
|
||||||
|
rc.CustomAbort(http.StatusForbidden, "")
|
||||||
|
}
|
||||||
|
|
||||||
if enableAddUserByAdmin && !isAdminLoginedUser {
|
if enableAddUserByAdmin && !isAdminLoginedUser {
|
||||||
log.Error("Self registration can only be used by admin user.\n")
|
log.Error("Self registration can only be used by admin user.\n")
|
||||||
rc.CustomAbort(http.StatusForbidden, "")
|
rc.CustomAbort(http.StatusForbidden, "")
|
||||||
|
@ -56,8 +56,10 @@
|
|||||||
<li><a id="aChangePassword" href="/changePassword" target="_blank"><span class="glyphicon glyphicon-pencil"></span> {{i18n .Lang "change_password"}}</a></li>
|
<li><a id="aChangePassword" href="/changePassword" target="_blank"><span class="glyphicon glyphicon-pencil"></span> {{i18n .Lang "change_password"}}</a></li>
|
||||||
<li role="separator" class="divider"></li>
|
<li role="separator" class="divider"></li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ if eq .IsAdminLoginedUser true }}
|
{{ if eq .AuthMode "db_auth" }}
|
||||||
<li><a id="aSelfSignUp" href="/register" target="_blank"><span class="glyphicon glyphicon-plus"></span> {{i18n .Lang "add_user"}}</a></li>
|
{{ if eq .IsAdminLoginedUser true }}
|
||||||
|
<li><a id="aSelfSignUp" href="/register" target="_blank"><span class="glyphicon glyphicon-plus"></span> {{i18n .Lang "add_user"}}</a></li>
|
||||||
|
{{ end }}
|
||||||
{{ end}}
|
{{ end}}
|
||||||
<li><a id="aLogout" href="#"><span class="glyphicon glyphicon-log-in"></span> {{i18n .Lang "log_out"}}</a></li>
|
<li><a id="aLogout" href="#"><span class="glyphicon glyphicon-log-in"></span> {{i18n .Lang "log_out"}}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user