Skip to content

Commit e66ca37

Browse files
committed
respect admin selection while creating a user
1 parent 126ba79 commit e66ca37

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

modules/auth/admin.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ import (
1212

1313
// AdminCreateUserForm form for admin to create user
1414
type AdminCreateUserForm struct {
15-
LoginType string `binding:"Required"`
16-
LoginName string
17-
UserName string `binding:"Required;AlphaDashDot;MaxSize(35)"`
18-
Email string `binding:"Required;Email;MaxSize(254)"`
19-
Password string `binding:"MaxSize(255)"`
20-
SendNotify bool
15+
LoginType string `binding:"Required"`
16+
LoginName string
17+
UserName string `binding:"Required;AlphaDashDot;MaxSize(35)"`
18+
Email string `binding:"Required;Email;MaxSize(254)"`
19+
Password string `binding:"MaxSize(255)"`
20+
SendNotify bool
21+
MustChangePassword bool
2122
}
2223

2324
// Validate validates form fields

options/locale/locale_en-US.ini

+1
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ sign_up_now = Need an account? Register now.
206206
sign_up_successful = Account was successfully created.
207207
confirmation_mail_sent_prompt = A new confirmation email has been sent to <b>%s</b>. Please check your inbox within the next %s to complete the registration process.
208208
must_change_password = Update your password
209+
allow_password_change = Require user to change password (recommended)
209210
reset_password_mail_sent_prompt = A confirmation email has been sent to <b>%s</b>. Please check your inbox within the next %s to complete the password reset process.
210211
active_your_account = Activate Your Account
211212
account_activated = Account has been activated

routers/admin/users.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func NewUserPost(ctx *context.Context, form auth.AdminCreateUserForm) {
8282
Passwd: form.Password,
8383
IsActive: true,
8484
LoginType: models.LoginPlain,
85-
MustChangePassword: true,
85+
MustChangePassword: form.MustChangePassword,
8686
}
8787

8888
if len(form.LoginType) > 0 {

templates/admin/user/new.tmpl

+7
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@
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">
46+
<div class="ui checkbox">
47+
<label><strong>{{.i18n.Tr "auth.allow_password_change" }}</strong></label>
48+
<input name="must_change_password" type="checkbox" checked>
49+
</div>
50+
</div>
51+
4552
<!-- Send register notify e-mail -->
4653
{{if .CanSendEmail}}
4754
<div class="inline field">

0 commit comments

Comments
 (0)