Merge pull request #632 from wknet123/master

Fixed self registration unchecked in UI.
This commit is contained in:
Daniel Jiang 2016-08-03 16:52:17 +08:00 committed by GitHub
commit 1d7e4d4e9b
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) {
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.

View File

@ -11,7 +11,7 @@ type SignUpController struct {
// Get renders sign up page
func (suc *SignUpController) Get() {
if suc.AuthMode != "db_auth" {
if suc.AuthMode != "db_auth" || !suc.SelfRegistration {
suc.CustomAbort(http.StatusUnauthorized, "Status unauthorized.")
}
suc.Data["AddNew"] = false

View File

@ -46,7 +46,7 @@
<div class="col-sm-offset-1 col-sm-10">
<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>
{{ 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>
{{ end }}
</div>