mirror of
https://github.com/goharbor/harbor
synced 2025-04-22 22:25:28 +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
|
||||
func (rc *RegisterController) Get() {
|
||||
|
||||
pageTitleKey := "page_title_registration"
|
||||
|
||||
if enableAddUserByAdmin {
|
||||
|
||||
if !isAdminLoginedUser {
|
||||
if enableAddUserByAdmin && !isAdminLoginedUser {
|
||||
log.Error("Self registration can only be used by admin user.\n")
|
||||
rc.Redirect("/signIn", http.StatusFound)
|
||||
}
|
||||
|
||||
pageTitleKey := "page_title_registration"
|
||||
|
||||
if isAdminLoginedUser {
|
||||
pageTitleKey = "page_title_add_user"
|
||||
}
|
||||
|
||||
@ -57,6 +56,11 @@ func (rc *RegisterController) Get() {
|
||||
// SignUp insert data into DB based on data in form.
|
||||
func (rc *CommonController) SignUp() {
|
||||
|
||||
authMode := os.Getenv("AUTH_MODE")
|
||||
if !(authMode == "" || authMode == "db_auth") {
|
||||
rc.CustomAbort(http.StatusForbidden, "")
|
||||
}
|
||||
|
||||
if enableAddUserByAdmin && !isAdminLoginedUser {
|
||||
log.Error("Self registration can only be used by admin user.\n")
|
||||
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 role="separator" class="divider"></li>
|
||||
{{ end }}
|
||||
{{ if eq .AuthMode "db_auth" }}
|
||||
{{ 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}}
|
||||
<li><a id="aLogout" href="#"><span class="glyphicon glyphicon-log-in"></span> {{i18n .Lang "log_out"}}</a></li>
|
||||
</ul>
|
||||
|
Loading…
x
Reference in New Issue
Block a user