forked from gitea/gitea
1
0
Fork 0

Fix new user form for non-local users (#8826) (#8828)

This commit is contained in:
Lauris BH 2019-11-05 02:19:32 +02:00 committed by Lunny Xiao
parent 1c65ecc1c6
commit 26457782c1
2 changed files with 12 additions and 10 deletions

View File

@ -79,12 +79,11 @@ func NewUserPost(ctx *context.Context, form auth.AdminCreateUserForm) {
} }
u := &models.User{ u := &models.User{
Name: form.UserName, Name: form.UserName,
Email: form.Email, Email: form.Email,
Passwd: form.Password, Passwd: form.Password,
IsActive: true, IsActive: true,
LoginType: models.LoginPlain, LoginType: models.LoginPlain,
MustChangePassword: form.MustChangePassword,
} }
if len(form.LoginType) > 0 { if len(form.LoginType) > 0 {
@ -95,9 +94,12 @@ func NewUserPost(ctx *context.Context, form auth.AdminCreateUserForm) {
u.LoginName = form.LoginName u.LoginName = form.LoginName
} }
} }
if !password.IsComplexEnough(form.Password) { if u.LoginType == models.LoginPlain {
ctx.RenderWithErr(ctx.Tr("form.password_complexity"), tplUserNew, &form) if !password.IsComplexEnough(form.Password) {
return ctx.RenderWithErr(ctx.Tr("form.password_complexity"), tplUserNew, &form)
return
}
u.MustChangePassword = form.MustChangePassword
} }
if err := models.CreateUser(u); err != nil { if err := models.CreateUser(u); err != nil {
switch { switch {

View File

@ -42,7 +42,7 @@
<input id="password" name="password" type="password" value="{{.password}}" {{if eq .login_type "0-0"}}required{{end}}> <input id="password" name="password" type="password" value="{{.password}}" {{if eq .login_type "0-0"}}required{{end}}>
</div> </div>
<div class="inline field"> <div class="inline field local{{if ne .login_type "0-0"}} hide{{end}}">
<div class="ui checkbox"> <div class="ui checkbox">
<label><strong>{{.i18n.Tr "auth.allow_password_change" }}</strong></label> <label><strong>{{.i18n.Tr "auth.allow_password_change" }}</strong></label>
<input name="must_change_password" type="checkbox" checked> <input name="must_change_password" type="checkbox" checked>