From 2c73ced0db2a3dc0402dc0cdc78538370bbf9e71 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 11 May 2014 10:37:31 -0400 Subject: [PATCH] Fix #173 --- public/js/app.js | 4 +++ routers/admin/auths.go | 14 ++++---- templates/admin/auths/edit.tmpl | 58 +++++++++++++++------------------ 3 files changed, 39 insertions(+), 37 deletions(-) diff --git a/public/js/app.js b/public/js/app.js index 162139986..ebb05d2d6 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -650,3 +650,7 @@ function initRepoSetting() { } }); })(jQuery); + +String.prototype.endsWith = function(suffix) { + return this.indexOf(suffix, this.length - suffix.length) !== -1; +}; diff --git a/routers/admin/auths.go b/routers/admin/auths.go index 495acefda..1822fd69a 100644 --- a/routers/admin/auths.go +++ b/routers/admin/auths.go @@ -9,6 +9,7 @@ import ( "github.com/go-martini/martini" "github.com/go-xorm/core" + "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/auth" "github.com/gogits/gogs/modules/auth/ldap" @@ -114,7 +115,8 @@ func EditAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) { } var config core.Conversion - if form.Type == models.LT_LDAP { + switch form.Type { + case models.LT_LDAP: config = &models.LDAPConfig{ Ldapsource: ldap.Ldapsource{ Host: form.Host, @@ -127,13 +129,16 @@ func EditAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) { Name: form.AuthName, }, } - } else if form.Type == models.LT_SMTP { + case models.LT_SMTP: config = &models.SMTPConfig{ Auth: form.SmtpAuth, Host: form.Host, Port: form.Port, TLS: form.Tls, } + default: + ctx.Error(400) + return } u := models.LoginSource{ @@ -145,10 +150,7 @@ func EditAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) { } if err := models.UpdateSource(&u); err != nil { - switch err { - default: - ctx.Handle(500, "admin.auths.EditAuth", err) - } + ctx.Handle(500, "admin.auths.EditAuth", err) return } diff --git a/templates/admin/auths/edit.tmpl b/templates/admin/auths/edit.tmpl index 9ebc0aa4c..2c7a5754b 100644 --- a/templates/admin/auths/edit.tmpl +++ b/templates/admin/auths/edit.tmpl @@ -32,7 +32,6 @@ {{if eq $type 2}} -
@@ -81,44 +80,41 @@
- {{else}} - {{if eq $type 3}} - + {{else if eq $type 3}}
- -
- -
+ +
+
+
-
- -
- -
+
+ +
+
+
-
- -
- -
+
+ +
+
+
-
- -
- -
+
+ +
+
- {{end}} +
{{end}}