summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2017-03-17 06:55:04 +0100
committerLunny Xiao <xiaolunwen@gmail.com>2017-03-17 13:55:04 +0800
commit7a81cd16c5341b4773e11a84c7b231d23e5f56d9 (patch)
treed41173341768b44e839a8d9046444fbff9ac4f21
parentebbcf6fe12151394d18bc1f04a6a25c9ab0627d5 (diff)
downloadgitea-7a81cd16c5341b4773e11a84c7b231d23e5f56d9.tar.gz
gitea-7a81cd16c5341b4773e11a84c7b231d23e5f56d9.zip
Refactor admin/auth/new.tmpl (#1277)
-rw-r--r--templates/admin/auth/new.tmpl119
-rw-r--r--templates/admin/auth/source/ldap.tmpl65
-rw-r--r--templates/admin/auth/source/oauth.tmpl23
-rw-r--r--templates/admin/auth/source/smtp.tmpl28
4 files changed, 119 insertions, 116 deletions
diff --git a/templates/admin/auth/new.tmpl b/templates/admin/auth/new.tmpl
index 59990fc37e..a18a782fc1 100644
--- a/templates/admin/auth/new.tmpl
+++ b/templates/admin/auth/new.tmpl
@@ -29,101 +29,10 @@
</div>
<!-- LDAP and DLDAP -->
- <div class="ldap dldap field {{if not (or (eq .type 2) (eq .type 5))}}hide{{end}}">
- <div class="inline required field {{if .Err_SecurityProtocol}}error{{end}}">
- <label>{{.i18n.Tr "admin.auths.security_protocol"}}</label>
- <div class="ui selection security-protocol dropdown">
- <input type="hidden" id="security_protocol" name="security_protocol" value="{{.security_protocol}}">
- <div class="text">{{.CurrentSecurityProtocol}}</div>
- <i class="dropdown icon"></i>
- <div class="menu">
- {{range .SecurityProtocols}}
- <div class="item" data-value="{{.Type}}">{{.Name}}</div>
- {{end}}
- </div>
- </div>
- </div>
- <div class="required field">
- <label for="host">{{.i18n.Tr "admin.auths.host"}}</label>
- <input id="host" name="host" value="{{.host}}" placeholder="e.g. mydomain.com">
- </div>
- <div class="required field">
- <label for="port">{{.i18n.Tr "admin.auths.port"}}</label>
- <input id="port" name="port" value="{{.port}}" placeholder="e.g. 636">
- </div>
- <div class="ldap field {{if not (eq .type 2)}}hide{{end}}">
- <label for="bind_dn">{{.i18n.Tr "admin.auths.bind_dn"}}</label>
- <input id="bind_dn" name="bind_dn" value="{{.bind_dn}}" placeholder="e.g. cn=Search,dc=mydomain,dc=com">
- </div>
- <input class="fake" type="password">
- <div class="ldap field {{if not (eq .type 2)}}hide{{end}}">
- <label for="bind_password">{{.i18n.Tr "admin.auths.bind_password"}}</label>
- <input id="bind_password" name="bind_password" type="password" value="{{.bind_password}}">
- <p class="help text red">{{.i18n.Tr "admin.auths.bind_password_helper"}}</p>
- </div>
- <div class="ldap required field {{if not (eq .type 2)}}hide{{end}}">
- <label for="user_base">{{.i18n.Tr "admin.auths.user_base"}}</label>
- <input id="user_base" name="user_base" value="{{.user_base}}" placeholder="e.g. ou=Users,dc=mydomain,dc=com">
- </div>
- <div class="dldap required field {{if not (eq .type 5)}}hide{{end}}">
- <label for="user_dn">{{.i18n.Tr "admin.auths.user_dn"}}</label>
- <input id="user_dn" name="user_dn" value="{{.user_dn}}" placeholder="e.g. uid=%s,ou=Users,dc=mydomain,dc=com">
- </div>
- <div class="required field">
- <label for="filter">{{.i18n.Tr "admin.auths.filter"}}</label>
- <input id="filter" name="filter" value="{{.filter}}" placeholder="e.g. (&(objectClass=posixAccount)(uid=%s))">
- </div>
- <div class="field">
- <label for="admin_filter">{{.i18n.Tr "admin.auths.admin_filter"}}</label>
- <input id="admin_filter" name="admin_filter" value="{{.admin_filter}}">
- </div>
- <div class="field">
- <label for="attribute_username">{{.i18n.Tr "admin.auths.attribute_username"}}</label>
- <input id="attribute_username" name="attribute_username" value="{{.attribute_username}}" placeholder="{{.i18n.Tr "admin.auths.attribute_username_placeholder"}}">
- </div>
- <div class="field">
- <label for="attribute_name">{{.i18n.Tr "admin.auths.attribute_name"}}</label>
- <input id="attribute_name" name="attribute_name" value="{{.attribute_name}}">
- </div>
- <div class="field">
- <label for="attribute_surname">{{.i18n.Tr "admin.auths.attribute_surname"}}</label>
- <input id="attribute_surname" name="attribute_surname" value="{{.attribute_surname}}">
- </div>
- <div class="required field">
- <label for="attribute_mail">{{.i18n.Tr "admin.auths.attribute_mail"}}</label>
- <input id="attribute_mail" name="attribute_mail" value="{{.attribute_mail}}" placeholder="e.g. mail">
- </div>
- </div>
+ {{ template "admin/auth/source/ldap" . }}
<!-- SMTP -->
- <div class="smtp field {{if not (eq .type 3)}}hide{{end}}">
- <div class="inline required field">
- <label>{{.i18n.Tr "admin.auths.smtp_auth"}}</label>
- <div class="ui selection type dropdown">
- <input type="hidden" id="smtp_auth" name="smtp_auth" value="{{.smtp_auth}}">
- <div class="text">{{.smtp_auth}}</div>
- <i class="dropdown icon"></i>
- <div class="menu">
- {{range .SMTPAuths}}
- <div class="item" data-value="{{.}}">{{.}}</div>
- {{end}}
- </div>
- </div>
- </div>
- <div class="required field">
- <label for="smtp_host">{{.i18n.Tr "admin.auths.smtphost"}}</label>
- <input id="smtp_host" name="smtp_host" value="{{.smtp_host}}">
- </div>
- <div class="required field">
- <label for="smtp_port">{{.i18n.Tr "admin.auths.smtpport"}}</label>
- <input id="smtp_port" name="smtp_port" value="{{.smtp_port}}">
- </div>
- <div class="field">
- <label for="allowed_domains">{{.i18n.Tr "admin.auths.allowed_domains"}}</label>
- <input id="allowed_domains" name="allowed_domains" value="{{.allowed_domains}}">
- <p class="help">{{.i18n.Tr "admin.auths.allowed_domains_helper"}}</p>
- </div>
- </div>
+ {{ template "admin/auth/source/smtp" . }}
<!-- PAM -->
<div class="pam required field {{if not (eq .type 4)}}hide{{end}}">
@@ -132,29 +41,7 @@
</div>
<!-- OAuth2 -->
- <div class="oauth2 field {{if not (eq .type 6)}}hide{{end}}">
- <div class="inline required field">
- <label>{{.i18n.Tr "admin.auths.oauth2_provider"}}</label>
- <div class="ui selection type dropdown">
- <input type="hidden" id="oauth2_provider" name="oauth2_provider" value="{{.oauth2_provider}}">
- <div class="text">{{.oauth2_provider}}</div>
- <i class="dropdown icon"></i>
- <div class="menu">
- {{range $key, $value := .OAuth2Providers}}
- <div class="item" data-value="{{$key}}">{{$value.DisplayName}}</div>
- {{end}}
- </div>
- </div>
- </div>
- <div class="required field">
- <label for="oauth2_key">{{.i18n.Tr "admin.auths.oauth2_clientID"}}</label>
- <input id="oauth2_key" name="oauth2_key" value="{{.oauth2_key}}">
- </div>
- <div class="required field">
- <label for="oauth2_secret">{{.i18n.Tr "admin.auths.oauth2_clientSecret"}}</label>
- <input id="oauth2_secret" name="oauth2_secret" value="{{.oauth2_secret}}">
- </div>
- </div>
+ {{ template "admin/auth/source/oauth" . }}
<div class="ldap field">
<div class="ui checkbox">
diff --git a/templates/admin/auth/source/ldap.tmpl b/templates/admin/auth/source/ldap.tmpl
new file mode 100644
index 0000000000..2131950212
--- /dev/null
+++ b/templates/admin/auth/source/ldap.tmpl
@@ -0,0 +1,65 @@
+<div class="ldap dldap field {{if not (or (eq .type 2) (eq .type 5))}}hide{{end}}">
+ <div class="inline required field {{if .Err_SecurityProtocol}}error{{end}}">
+ <label>{{.i18n.Tr "admin.auths.security_protocol"}}</label>
+ <div class="ui selection security-protocol dropdown">
+ <input type="hidden" id="security_protocol" name="security_protocol" value="{{.security_protocol}}">
+ <div class="text">{{.CurrentSecurityProtocol}}</div>
+ <i class="dropdown icon"></i>
+ <div class="menu">
+ {{range .SecurityProtocols}}
+ <div class="item" data-value="{{.Type}}">{{.Name}}</div>
+ {{end}}
+ </div>
+ </div>
+ </div>
+ <div class="required field">
+ <label for="host">{{.i18n.Tr "admin.auths.host"}}</label>
+ <input id="host" name="host" value="{{.host}}" placeholder="e.g. mydomain.com">
+ </div>
+ <div class="required field">
+ <label for="port">{{.i18n.Tr "admin.auths.port"}}</label>
+ <input id="port" name="port" value="{{.port}}" placeholder="e.g. 636">
+ </div>
+ <div class="ldap field {{if not (eq .type 2)}}hide{{end}}">
+ <label for="bind_dn">{{.i18n.Tr "admin.auths.bind_dn"}}</label>
+ <input id="bind_dn" name="bind_dn" value="{{.bind_dn}}" placeholder="e.g. cn=Search,dc=mydomain,dc=com">
+ </div>
+ <input class="fake" type="password">
+ <div class="ldap field {{if not (eq .type 2)}}hide{{end}}">
+ <label for="bind_password">{{.i18n.Tr "admin.auths.bind_password"}}</label>
+ <input id="bind_password" name="bind_password" type="password" value="{{.bind_password}}">
+ <p class="help text red">{{.i18n.Tr "admin.auths.bind_password_helper"}}</p>
+ </div>
+ <div class="ldap required field {{if not (eq .type 2)}}hide{{end}}">
+ <label for="user_base">{{.i18n.Tr "admin.auths.user_base"}}</label>
+ <input id="user_base" name="user_base" value="{{.user_base}}" placeholder="e.g. ou=Users,dc=mydomain,dc=com">
+ </div>
+ <div class="dldap required field {{if not (eq .type 5)}}hide{{end}}">
+ <label for="user_dn">{{.i18n.Tr "admin.auths.user_dn"}}</label>
+ <input id="user_dn" name="user_dn" value="{{.user_dn}}" placeholder="e.g. uid=%s,ou=Users,dc=mydomain,dc=com">
+ </div>
+ <div class="required field">
+ <label for="filter">{{.i18n.Tr "admin.auths.filter"}}</label>
+ <input id="filter" name="filter" value="{{.filter}}" placeholder="e.g. (&(objectClass=posixAccount)(uid=%s))">
+ </div>
+ <div class="field">
+ <label for="admin_filter">{{.i18n.Tr "admin.auths.admin_filter"}}</label>
+ <input id="admin_filter" name="admin_filter" value="{{.admin_filter}}">
+ </div>
+ <div class="field">
+ <label for="attribute_username">{{.i18n.Tr "admin.auths.attribute_username"}}</label>
+ <input id="attribute_username" name="attribute_username" value="{{.attribute_username}}" placeholder="{{.i18n.Tr "admin.auths.attribute_username_placeholder"}}">
+ </div>
+ <div class="field">
+ <label for="attribute_name">{{.i18n.Tr "admin.auths.attribute_name"}}</label>
+ <input id="attribute_name" name="attribute_name" value="{{.attribute_name}}">
+ </div>
+ <div class="field">
+ <label for="attribute_surname">{{.i18n.Tr "admin.auths.attribute_surname"}}</label>
+ <input id="attribute_surname" name="attribute_surname" value="{{.attribute_surname}}">
+ </div>
+ <div class="required field">
+ <label for="attribute_mail">{{.i18n.Tr "admin.auths.attribute_mail"}}</label>
+ <input id="attribute_mail" name="attribute_mail" value="{{.attribute_mail}}" placeholder="e.g. mail">
+ </div>
+</div>
diff --git a/templates/admin/auth/source/oauth.tmpl b/templates/admin/auth/source/oauth.tmpl
new file mode 100644
index 0000000000..4d8e12e028
--- /dev/null
+++ b/templates/admin/auth/source/oauth.tmpl
@@ -0,0 +1,23 @@
+<div class="oauth2 field {{if not (eq .type 6)}}hide{{end}}">
+ <div class="inline required field">
+ <label>{{.i18n.Tr "admin.auths.oauth2_provider"}}</label>
+ <div class="ui selection type dropdown">
+ <input type="hidden" id="oauth2_provider" name="oauth2_provider" value="{{.oauth2_provider}}">
+ <div class="text">{{.oauth2_provider}}</div>
+ <i class="dropdown icon"></i>
+ <div class="menu">
+ {{range $key, $value := .OAuth2Providers}}
+ <div class="item" data-value="{{$key}}">{{$value.DisplayName}}</div>
+ {{end}}
+ </div>
+ </div>
+ </div>
+ <div class="required field">
+ <label for="oauth2_key">{{.i18n.Tr "admin.auths.oauth2_clientID"}}</label>
+ <input id="oauth2_key" name="oauth2_key" value="{{.oauth2_key}}">
+ </div>
+ <div class="required field">
+ <label for="oauth2_secret">{{.i18n.Tr "admin.auths.oauth2_clientSecret"}}</label>
+ <input id="oauth2_secret" name="oauth2_secret" value="{{.oauth2_secret}}">
+ </div>
+</div>
diff --git a/templates/admin/auth/source/smtp.tmpl b/templates/admin/auth/source/smtp.tmpl
new file mode 100644
index 0000000000..d4c83c171a
--- /dev/null
+++ b/templates/admin/auth/source/smtp.tmpl
@@ -0,0 +1,28 @@
+<div class="smtp field {{if not (eq .type 3)}}hide{{end}}">
+ <div class="inline required field">
+ <label>{{.i18n.Tr "admin.auths.smtp_auth"}}</label>
+ <div class="ui selection type dropdown">
+ <input type="hidden" id="smtp_auth" name="smtp_auth" value="{{.smtp_auth}}">
+ <div class="text">{{.smtp_auth}}</div>
+ <i class="dropdown icon"></i>
+ <div class="menu">
+ {{range .SMTPAuths}}
+ <div class="item" data-value="{{.}}">{{.}}</div>
+ {{end}}
+ </div>
+ </div>
+ </div>
+ <div class="required field">
+ <label for="smtp_host">{{.i18n.Tr "admin.auths.smtphost"}}</label>
+ <input id="smtp_host" name="smtp_host" value="{{.smtp_host}}">
+ </div>
+ <div class="required field">
+ <label for="smtp_port">{{.i18n.Tr "admin.auths.smtpport"}}</label>
+ <input id="smtp_port" name="smtp_port" value="{{.smtp_port}}">
+ </div>
+ <div class="field">
+ <label for="allowed_domains">{{.i18n.Tr "admin.auths.allowed_domains"}}</label>
+ <input id="allowed_domains" name="allowed_domains" value="{{.allowed_domains}}">
+ <p class="help">{{.i18n.Tr "admin.auths.allowed_domains_helper"}}</p>
+ </div>
+</div>