diff options
author | Lauris BH <lauris@nix.lv> | 2019-11-04 21:10:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-04 21:10:37 +0200 |
commit | 86a44f6b48cf4e814452a71d97e42e486237a307 (patch) | |
tree | 123ced125b46d13e4fddb18b94765ea0ed498e0f | |
parent | 3fb9e3afe36e72f855272eb6c43d47824e414117 (diff) | |
download | gitea-86a44f6b48cf4e814452a71d97e42e486237a307.tar.gz gitea-86a44f6b48cf4e814452a71d97e42e486237a307.zip |
Fix new user form for non-local users (#8826)
-rw-r--r-- | routers/admin/users.go | 20 | ||||
-rw-r--r-- | templates/admin/user/new.tmpl | 2 |
2 files changed, 12 insertions, 10 deletions
diff --git a/routers/admin/users.go b/routers/admin/users.go index fdc4e0e371..2284f21838 100644 --- a/routers/admin/users.go +++ b/routers/admin/users.go @@ -79,12 +79,11 @@ func NewUserPost(ctx *context.Context, form auth.AdminCreateUserForm) { } u := &models.User{ - Name: form.UserName, - Email: form.Email, - Passwd: form.Password, - IsActive: true, - LoginType: models.LoginPlain, - MustChangePassword: form.MustChangePassword, + Name: form.UserName, + Email: form.Email, + Passwd: form.Password, + IsActive: true, + LoginType: models.LoginPlain, } if len(form.LoginType) > 0 { @@ -95,9 +94,12 @@ func NewUserPost(ctx *context.Context, form auth.AdminCreateUserForm) { u.LoginName = form.LoginName } } - if !password.IsComplexEnough(form.Password) { - ctx.RenderWithErr(ctx.Tr("form.password_complexity"), tplUserNew, &form) - return + if u.LoginType == models.LoginPlain { + if !password.IsComplexEnough(form.Password) { + ctx.RenderWithErr(ctx.Tr("form.password_complexity"), tplUserNew, &form) + return + } + u.MustChangePassword = form.MustChangePassword } if err := models.CreateUser(u); err != nil { switch { diff --git a/templates/admin/user/new.tmpl b/templates/admin/user/new.tmpl index b9e326e734..06b7d70efe 100644 --- a/templates/admin/user/new.tmpl +++ b/templates/admin/user/new.tmpl @@ -42,7 +42,7 @@ <input id="password" name="password" type="password" value="{{.password}}" {{if eq .login_type "0-0"}}required{{end}}> </div> - <div class="inline field"> + <div class="inline field local{{if ne .login_type "0-0"}} hide{{end}}"> <div class="ui checkbox"> <label><strong>{{.i18n.Tr "auth.allow_password_change" }}</strong></label> <input name="must_change_password" type="checkbox" checked> |