Skip to content

Commit 7548037

Browse files
jolheiserlafriks
authored andcommitted
Adds MustChangePassword to user create/edit API, defaults to true (go-gitea#6193)
Signed-off-by: jolheiser <[email protected]>
1 parent b1ffe7e commit 7548037

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

Gopkg.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

routers/api/v1/admin/user.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,16 @@ func CreateUser(ctx *context.APIContext, form api.CreateUserOption) {
5656
// "422":
5757
// "$ref": "#/responses/validationError"
5858
u := &models.User{
59-
Name: form.Username,
60-
FullName: form.FullName,
61-
Email: form.Email,
62-
Passwd: form.Password,
63-
IsActive: true,
64-
LoginType: models.LoginPlain,
59+
Name: form.Username,
60+
FullName: form.FullName,
61+
Email: form.Email,
62+
Passwd: form.Password,
63+
MustChangePassword: true,
64+
IsActive: true,
65+
LoginType: models.LoginPlain,
66+
}
67+
if form.MustChangePassword != nil {
68+
u.MustChangePassword = *form.MustChangePassword
6569
}
6670

6771
parseLoginSource(ctx, u, form.SourceID, form.LoginName)
@@ -135,6 +139,10 @@ func EditUser(ctx *context.APIContext, form api.EditUserOption) {
135139
u.HashPassword(form.Password)
136140
}
137141

142+
if form.MustChangePassword != nil {
143+
u.MustChangePassword = *form.MustChangePassword
144+
}
145+
138146
u.LoginName = form.LoginName
139147
u.FullName = form.FullName
140148
u.Email = form.Email

vendor/code.gitea.io/sdk/gitea/admin_user.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)