Skip to content

Commit 2645778

Browse files
lafrikslunny
authored andcommitted
Fix new user form for non-local users (#8826) (#8828)
1 parent 1c65ecc commit 2645778

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

routers/admin/users.go

+11-9
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,11 @@ func NewUserPost(ctx *context.Context, form auth.AdminCreateUserForm) {
7979
}
8080

8181
u := &models.User{
82-
Name: form.UserName,
83-
Email: form.Email,
84-
Passwd: form.Password,
85-
IsActive: true,
86-
LoginType: models.LoginPlain,
87-
MustChangePassword: form.MustChangePassword,
82+
Name: form.UserName,
83+
Email: form.Email,
84+
Passwd: form.Password,
85+
IsActive: true,
86+
LoginType: models.LoginPlain,
8887
}
8988

9089
if len(form.LoginType) > 0 {
@@ -95,9 +94,12 @@ func NewUserPost(ctx *context.Context, form auth.AdminCreateUserForm) {
9594
u.LoginName = form.LoginName
9695
}
9796
}
98-
if !password.IsComplexEnough(form.Password) {
99-
ctx.RenderWithErr(ctx.Tr("form.password_complexity"), tplUserNew, &form)
100-
return
97+
if u.LoginType == models.LoginPlain {
98+
if !password.IsComplexEnough(form.Password) {
99+
ctx.RenderWithErr(ctx.Tr("form.password_complexity"), tplUserNew, &form)
100+
return
101+
}
102+
u.MustChangePassword = form.MustChangePassword
101103
}
102104
if err := models.CreateUser(u); err != nil {
103105
switch {

templates/admin/user/new.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<input id="password" name="password" type="password" value="{{.password}}" {{if eq .login_type "0-0"}}required{{end}}>
4343
</div>
4444

45-
<div class="inline field">
45+
<div class="inline field local{{if ne .login_type "0-0"}} hide{{end}}">
4646
<div class="ui checkbox">
4747
<label><strong>{{.i18n.Tr "auth.allow_password_change" }}</strong></label>
4848
<input name="must_change_password" type="checkbox" checked>

0 commit comments

Comments
 (0)