#1124 LDAP add and edit form are misleading

This commit is contained in:
Unknwon 2015-03-24 19:04:16 -04:00
parent 9c67a19332
commit 211596f407
4 changed files with 57 additions and 45 deletions

View File

@ -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"`
}

View File

@ -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"))
}

View File

@ -52,11 +52,11 @@
<input class="ipt ipt-large ipt-radius {{if .Err_Attributes}}ipt-error{{end}}" id="attribute_username" name="attribute_username" value="{{.Source.LDAP.AttributeUsername}}" />
</div>
<div class="field">
<label class="req" for="attribute_name">{{.i18n.Tr "admin.auths.attribute_name"}}</label>
<label for="attribute_name">{{.i18n.Tr "admin.auths.attribute_name"}}</label>
<input class="ipt ipt-large ipt-radius {{if .Err_Attributes}}ipt-error{{end}}" id="attribute_name" name="attribute_name" value="{{.Source.LDAP.AttributeName}}" />
</div>
<div class="field">
<label class="req" for="attribute_surname">{{.i18n.Tr "admin.auths.attribute_surname"}}</label>
<label for="attribute_surname">{{.i18n.Tr "admin.auths.attribute_surname"}}</label>
<input class="ipt ipt-large ipt-radius {{if .Err_Attributes}}ipt-error{{end}}" id="attribute_surname" name="attribute_surname" value="{{.Source.LDAP.AttributeSurname}}" />
</div>
<div class="field">
@ -75,7 +75,7 @@
{{else if eq $type 3}}
<div class="field">
<label class="req">{{.i18n.Tr "admin.auths.smtp_auth"}}</label>
<select name="smtpauth">
<select name="smtp_auth">
{{$auth := .Source.SMTP.Auth}}
{{range .SMTPAuths}}
<option value="{{.}}"
@ -84,12 +84,12 @@
</select>
</div>
<div class="field">
<label class="req" for="smtphost">{{.i18n.Tr "admin.auths.smtphost"}}</label>
<input class="ipt ipt-large ipt-radius {{if .Err_SmtpHost}}ipt-error{{end}}" id="smtphost" name="smtphost" value="{{.Source.SMTP.Host}}" />
<label class="req" for="smtp_host">{{.i18n.Tr "admin.auths.smtphost"}}</label>
<input class="ipt ipt-large ipt-radius {{if .Err_SmtpHost}}ipt-error{{end}}" id="smtp_host" name="smtp_host" value="{{.Source.SMTP.Host}}" />
</div>
<div class="field">
<label class="req" for="smtpport">{{.i18n.Tr "admin.auths.smtpport"}}</label>
<input class="ipt ipt-large ipt-radius {{if .Err_SmtpPort}}ipt-error{{end}}" id="smtpport" name="smtpport" value="{{.Source.SMTP.Port}}" />
<label class="req" for="smtp_port">{{.i18n.Tr "admin.auths.smtpport"}}</label>
<input class="ipt ipt-large ipt-radius {{if .Err_SmtpPort}}ipt-error{{end}}" id="smtp_port" name="smtp_port" value="{{.Source.SMTP.Port}}" />
</div>
{{end}}

View File

@ -44,8 +44,20 @@
<input class="ipt ipt-large ipt-radius {{if .Err_BaseDN}}ipt-error{{end}}" id="base_dn" name="base_dn" value="{{.base_dn}}" />
</div>
<div class="field">
<label class="req" for="attributes">{{.i18n.Tr "admin.auths.attributes"}}</label>
<input class="ipt ipt-large ipt-radius {{if .Err_Attributes}}ipt-error{{end}}" id="attributes" name="attributes" value="{{.attributes}}" />
<label class="req" for="attribute_username">{{.i18n.Tr "admin.auths.attribute_username"}}</label>
<input class="ipt ipt-large ipt-radius {{if .Err_AttributeUsername}}ipt-error{{end}}" id="attribute_username" name="attribute_username" value="{{.attribute_username}}" />
</div>
<div class="field">
<label for="attribute_name">{{.i18n.Tr "admin.auths.attribute_name"}}</label>
<input class="ipt ipt-large ipt-radius {{if .Err_AttributeName}}ipt-error{{end}}" 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 class="ipt ipt-large ipt-radius {{if .Err_AttributeSurname}}ipt-error{{end}}" id="attribute_surname" name="attribute_surname" value="{{.attribute_surname}}" />
</div>
<div class="field">
<label class="req" for="attribute_mail">{{.i18n.Tr "admin.auths.attribute_mail"}}</label>
<input class="ipt ipt-large ipt-radius {{if .Err_AttributeMail}}ipt-error{{end}}" id="attribute_mail" name="attribute_mail" value="{{.attribute_mail}}" />
</div>
<div class="field">
<label class="req" for="filter">{{.i18n.Tr "admin.auths.filter"}}</label>
@ -59,19 +71,19 @@
<div class="smtp hidden">
<div class="field">
<label class="req">{{.i18n.Tr "admin.auths.smtp_auth"}}</label>
<select name="smtpauth">
<select name="smtp_auth">
{{range .SMTPAuths}}
<option value="{{.}}">{{.}}</option>
{{end}}
</select>
</div>
<div class="field">
<label class="req" for="smtphost">{{.i18n.Tr "admin.auths.smtphost"}}</label>
<input class="ipt ipt-large ipt-radius {{if .Err_SmtpHost}}ipt-error{{end}}" id="smtphost" name="smtphost" value="{{.smtphost}}" />
<label class="req" for="smtp_host">{{.i18n.Tr "admin.auths.smtphost"}}</label>
<input class="ipt ipt-large ipt-radius {{if .Err_SmtpHost}}ipt-error{{end}}" id="smtp_host" name="smtp_host" value="{{.smtp_host}}" />
</div>
<div class="field">
<label class="req" for="smtpport">{{.i18n.Tr "admin.auths.smtpport"}}</label>
<input class="ipt ipt-large ipt-radius {{if .Err_SmtpPort}}ipt-error{{end}}" id="smtpport" name="smtpport" value="{{.smtpport}}" />
<label class="req" for="smtp_port">{{.i18n.Tr "admin.auths.smtpport"}}</label>
<input class="ipt ipt-large ipt-radius {{if .Err_SmtpPort}}ipt-error{{end}}" id="smtp_port" name="smtp_port" value="{{.smtp_port}}" />
</div>
</div>
<div class="field">