fixed self registration unchecked.

This commit is contained in:
kunw 2016-08-03 15:43:43 +08:00
parent 9b106d223d
commit 3fe35c0f9b
3 changed files with 8 additions and 2 deletions

View File

@ -107,6 +107,12 @@ func (b *BaseController) Prepare() {
if _, err := os.Stat(filepath.Join("static", "resources", "js", "harbor.app.min.js")); os.IsNotExist(err) { if _, err := os.Stat(filepath.Join("static", "resources", "js", "harbor.app.min.js")); os.IsNotExist(err) {
b.UseCompressedJS = false b.UseCompressedJS = false
} }
selfRegistration := strings.ToLower(os.Getenv("SELF_REGISTRATION"))
if selfRegistration == "on" {
b.SelfRegistration = true
}
b.Data["SelfRegistration"] = b.SelfRegistration
} }
// Forward to setup layout and template for content for a page. // Forward to setup layout and template for content for a page.

View File

@ -11,7 +11,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" { if suc.AuthMode != "db_auth" || !suc.SelfRegistration {
suc.CustomAbort(http.StatusUnauthorized, "Status unauthorized.") suc.CustomAbort(http.StatusUnauthorized, "Status unauthorized.")
} }
suc.Data["AddNew"] = false suc.Data["AddNew"] = false

View File

@ -46,7 +46,7 @@
<div class="col-sm-offset-1 col-sm-10"> <div class="col-sm-offset-1 col-sm-10">
<div class="pull-right"> <div class="pull-right">
<button type="submit" class="btn btn-default" ng-click="vm.doSignIn(user)" loading-progress hide-target="false" toggle-in-progress="vm.signInTIP">// 'sign_in' | tr //</button> <button type="submit" class="btn btn-default" ng-click="vm.doSignIn(user)" loading-progress hide-target="false" toggle-in-progress="vm.signInTIP">// 'sign_in' | tr //</button>
{{ if eq .AuthMode "db_auth" }} {{ if and (eq .AuthMode "db_auth") (eq .SelfRegistration true) }}
<button type="button" class="btn btn-success" ng-click="vm.doSignUp()">// 'sign_up' | tr //</button> <button type="button" class="btn btn-success" ng-click="vm.doSignUp()">// 'sign_up' | tr //</button>
{{ end }} {{ end }}
</div> </div>