From c5dbc24ca45e99c51e86e35a57ddec7a9095bb01 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 11 May 2014 07:43:57 -0400 Subject: [PATCH] UI fix --- gogs.go | 2 +- modules/auth/authentication.go | 4 +--- routers/admin/auths.go | 28 ++++++++++++------------- templates/admin/auths/new.tmpl | 38 +++++++++++++++++++++------------- 4 files changed, 39 insertions(+), 33 deletions(-) diff --git a/gogs.go b/gogs.go index 3d6b4807a6..8d5b021c34 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/base" ) -const APP_VER = "0.3.3.0508 Alpha" +const APP_VER = "0.3.3.0511 Alpha" func init() { base.AppVer = APP_VER diff --git a/modules/auth/authentication.go b/modules/auth/authentication.go index 89ccc560f9..4456d2a5f7 100644 --- a/modules/auth/authentication.go +++ b/modules/auth/authentication.go @@ -27,9 +27,7 @@ type AuthenticationForm struct { MsAdSA string `form:"ms_ad_sa"` IsActived bool `form:"is_actived"` SmtpAuth string `form:"smtpauth"` - SmtpHost string `form:"smtphost"` - SmtpPort int `form:"smtpport"` - SmtpTls bool `form:"smtptls"` + Tls bool `form:"tls"` AllowAutoRegister bool `form:"allowautoregister"` } diff --git a/routers/admin/auths.go b/routers/admin/auths.go index c45bbaaba0..68fef21e8a 100644 --- a/routers/admin/auths.go +++ b/routers/admin/auths.go @@ -5,7 +5,6 @@ package admin import ( - "errors" "strings" "github.com/go-martini/martini" @@ -38,7 +37,8 @@ func NewAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) { } var u core.Conversion - if form.Type == models.LT_LDAP { + switch form.Type { + case models.LT_LDAP: u = &models.LDAPConfig{ Ldapsource: ldap.Ldapsource{ Host: form.Host, @@ -51,15 +51,16 @@ func NewAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) { Name: form.AuthName, }, } - } else if form.Type == models.LT_SMTP { + case models.LT_SMTP: u = &models.SMTPConfig{ Auth: form.SmtpAuth, - Host: form.SmtpHost, - Port: form.SmtpPort, - TLS: form.SmtpTls, + Host: form.Host, + Port: form.Port, + TLS: form.Tls, } - } else { - panic(errors.New("not allow type")) + default: + ctx.Error(400) + return } var source = &models.LoginSource{ @@ -71,10 +72,7 @@ func NewAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) { } if err := models.AddSource(source); err != nil { - switch err { - default: - ctx.Handle(500, "admin.auths.NewAuth", err) - } + ctx.Handle(500, "admin.auths.NewAuth", err) return } @@ -132,9 +130,9 @@ func EditAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) { } else if form.Type == models.LT_SMTP { config = &models.SMTPConfig{ Auth: form.SmtpAuth, - Host: form.SmtpHost, - Port: form.SmtpPort, - TLS: form.SmtpTls, + Host: form.Host, + Port: form.Port, + TLS: form.Tls, } } diff --git a/templates/admin/auths/new.tmpl b/templates/admin/auths/new.tmpl index 287c996c7f..e5dcb4339b 100644 --- a/templates/admin/auths/new.tmpl +++ b/templates/admin/auths/new.tmpl @@ -82,14 +82,13 @@