From 211596f407dbde1f755d0b309c7ecc707f116070 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Tue, 24 Mar 2015 19:04:16 -0400 Subject: [PATCH] #1124 LDAP add and edit form are misleading --- modules/auth/auth_form.go | 32 ++++++++++++++++---------------- routers/admin/auths.go | 30 +++++++++++++++--------------- templates/admin/auth/edit.tmpl | 14 +++++++------- templates/admin/auth/new.tmpl | 26 +++++++++++++++++++------- 4 files changed, 57 insertions(+), 45 deletions(-) diff --git a/modules/auth/auth_form.go b/modules/auth/auth_form.go index c7b9389600..7d45999914 100644 --- a/modules/auth/auth_form.go +++ b/modules/auth/auth_form.go @@ -10,25 +10,25 @@ import ( ) type AuthenticationForm struct { - Id int64 `form:"id"` - Type int `form:"type"` - AuthName string `form:"name" binding:"Required;MaxSize(50)"` - Domain string `form:"domain"` - Host string `form:"host"` - Port int `form:"port"` + ID int64 `form:"id"` + Type int + Name string `binding:"Required;MaxSize(50)"` + Domain string + Host string + Port int UseSSL bool `form:"usessl"` BaseDN string `form:"base_dn"` - AttributeUsername string `form:"attribute_username"` - AttributeName string `form:"attribute_name"` - AttributeSurname string `form:"attribute_surname"` - AttributeMail string `form:"attribute_mail"` - Filter string `form:"filter"` + AttributeUsername string + AttributeName string + AttributeSurname string + AttributeMail string + Filter string MsAdSA string `form:"ms_ad_sa"` - IsActived bool `form:"is_actived"` - SmtpAuth string `form:"smtpauth"` - SmtpHost string `form:"smtphost"` - SmtpPort int `form:"smtpport"` - Tls bool `form:"tls"` + IsActived bool + SMTPAuth string `form:"smtp_auth"` + SMTPHost string `form:"smtp_host"` + SMTPPort int `form:"smtp_port"` + TLS bool `form:"tls"` AllowAutoRegister bool `form:"allowautoregister"` } diff --git a/routers/admin/auths.go b/routers/admin/auths.go index dcb98d3303..b13b0bd134 100644 --- a/routers/admin/auths.go +++ b/routers/admin/auths.go @@ -74,15 +74,15 @@ func NewAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) { Filter: form.Filter, MsAdSAFormat: form.MsAdSA, Enabled: true, - Name: form.AuthName, + Name: form.Name, }, } case models.SMTP: u = &models.SMTPConfig{ - Auth: form.SmtpAuth, - Host: form.SmtpHost, - Port: form.SmtpPort, - TLS: form.Tls, + Auth: form.SMTPAuth, + Host: form.SMTPHost, + Port: form.SMTPPort, + TLS: form.TLS, } default: ctx.Error(400) @@ -91,7 +91,7 @@ func NewAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) { var source = &models.LoginSource{ Type: models.LoginType(form.Type), - Name: form.AuthName, + Name: form.Name, IsActived: true, AllowAutoRegister: form.AllowAutoRegister, Cfg: u, @@ -102,7 +102,7 @@ func NewAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) { return } - log.Trace("Authentication created by admin(%s): %s", ctx.User.Name, form.AuthName) + log.Trace("Authentication created by admin(%s): %s", ctx.User.Name, form.Name) ctx.Redirect(setting.AppSubUrl + "/admin/auths") } @@ -156,15 +156,15 @@ func EditAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) { Filter: form.Filter, MsAdSAFormat: form.MsAdSA, Enabled: true, - Name: form.AuthName, + Name: form.Name, }, } case models.SMTP: config = &models.SMTPConfig{ - Auth: form.SmtpAuth, - Host: form.SmtpHost, - Port: form.SmtpPort, - TLS: form.Tls, + Auth: form.SMTPAuth, + Host: form.SMTPHost, + Port: form.SMTPPort, + TLS: form.TLS, } default: ctx.Error(400) @@ -172,8 +172,8 @@ func EditAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) { } u := models.LoginSource{ - Id: form.Id, - Name: form.AuthName, + Id: form.ID, + Name: form.Name, IsActived: form.IsActived, Type: models.LoginType(form.Type), AllowAutoRegister: form.AllowAutoRegister, @@ -185,7 +185,7 @@ func EditAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) { return } - log.Trace("Authentication changed by admin(%s): %s", ctx.User.Name, form.AuthName) + log.Trace("Authentication changed by admin(%s): %s", ctx.User.Name, form.Name) ctx.Flash.Success(ctx.Tr("admin.auths.update_success")) ctx.Redirect(setting.AppSubUrl + "/admin/auths/" + ctx.Params(":authid")) } diff --git a/templates/admin/auth/edit.tmpl b/templates/admin/auth/edit.tmpl index 70bee6b43a..a178b71756 100644 --- a/templates/admin/auth/edit.tmpl +++ b/templates/admin/auth/edit.tmpl @@ -52,11 +52,11 @@
- +
- +
@@ -75,7 +75,7 @@ {{else if eq $type 3}}
- {{$auth := .Source.SMTP.Auth}} {{range .SMTPAuths}}
- - + +
- - + +
{{end}} diff --git a/templates/admin/auth/new.tmpl b/templates/admin/auth/new.tmpl index daae60e065..0d1f2ab417 100644 --- a/templates/admin/auth/new.tmpl +++ b/templates/admin/auth/new.tmpl @@ -44,8 +44,20 @@
- - + + +
+
+ + +
+
+ + +
+
+ +
@@ -59,19 +71,19 @@