diff options
author | John Olheiser <42128690+jolheiser@users.noreply.github.com> | 2019-02-27 13:37:57 -0600 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2019-02-27 21:37:57 +0200 |
commit | 7548037a64fd42bf11ad0d11a49fc3ae8dc731ff (patch) | |
tree | 4af3b0fb86c957409a126c38b493a0bca05eeb18 /routers/api/v1/admin | |
parent | b1ffe7e47b7752ba7c4f1733d0d6448d9c701078 (diff) | |
download | gitea-7548037a64fd42bf11ad0d11a49fc3ae8dc731ff.tar.gz gitea-7548037a64fd42bf11ad0d11a49fc3ae8dc731ff.zip |
Adds MustChangePassword to user create/edit API, defaults to true (#6193)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
Diffstat (limited to 'routers/api/v1/admin')
-rw-r--r-- | routers/api/v1/admin/user.go | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go index e35beffc92..cf52d649ad 100644 --- a/routers/api/v1/admin/user.go +++ b/routers/api/v1/admin/user.go @@ -56,12 +56,16 @@ func CreateUser(ctx *context.APIContext, form api.CreateUserOption) { // "422": // "$ref": "#/responses/validationError" u := &models.User{ - Name: form.Username, - FullName: form.FullName, - Email: form.Email, - Passwd: form.Password, - IsActive: true, - LoginType: models.LoginPlain, + Name: form.Username, + FullName: form.FullName, + Email: form.Email, + Passwd: form.Password, + MustChangePassword: true, + IsActive: true, + LoginType: models.LoginPlain, + } + if form.MustChangePassword != nil { + u.MustChangePassword = *form.MustChangePassword } parseLoginSource(ctx, u, form.SourceID, form.LoginName) @@ -135,6 +139,10 @@ func EditUser(ctx *context.APIContext, form api.EditUserOption) { u.HashPassword(form.Password) } + if form.MustChangePassword != nil { + u.MustChangePassword = *form.MustChangePassword + } + u.LoginName = form.LoginName u.FullName = form.FullName u.Email = form.Email |