mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-01 05:36:19 +01:00
Adds MustChangePassword to user create/edit API, defaults to true (#6193)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
This commit is contained in:
parent
b1ffe7e47b
commit
7548037a64
3 changed files with 18 additions and 10 deletions
4
Gopkg.lock
generated
4
Gopkg.lock
generated
|
@ -11,11 +11,11 @@
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
digest = "1:784d7948aaae61b9fe50aa15c69a62fb277268a47ed006748a7e25fa61b841c9"
|
digest = "1:59b2036a2d4b51fc91018adebd33ec4a893aa2b11af3a606445fe8df5640f514"
|
||||||
name = "code.gitea.io/sdk"
|
name = "code.gitea.io/sdk"
|
||||||
packages = ["gitea"]
|
packages = ["gitea"]
|
||||||
pruneopts = "NUT"
|
pruneopts = "NUT"
|
||||||
revision = "4a15722a627a9cf62a203a066e724e82556b3845"
|
revision = "9c4f6485997bcff568e30cfe45165018ac5772c1"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
digest = "1:5d72bbcc9c8667b11c3dc3cbe681c5a6f71e5096744c0bf7726ab5c6425d5dc4"
|
digest = "1:5d72bbcc9c8667b11c3dc3cbe681c5a6f71e5096744c0bf7726ab5c6425d5dc4"
|
||||||
|
|
|
@ -56,12 +56,16 @@ func CreateUser(ctx *context.APIContext, form api.CreateUserOption) {
|
||||||
// "422":
|
// "422":
|
||||||
// "$ref": "#/responses/validationError"
|
// "$ref": "#/responses/validationError"
|
||||||
u := &models.User{
|
u := &models.User{
|
||||||
Name: form.Username,
|
Name: form.Username,
|
||||||
FullName: form.FullName,
|
FullName: form.FullName,
|
||||||
Email: form.Email,
|
Email: form.Email,
|
||||||
Passwd: form.Password,
|
Passwd: form.Password,
|
||||||
IsActive: true,
|
MustChangePassword: true,
|
||||||
LoginType: models.LoginPlain,
|
IsActive: true,
|
||||||
|
LoginType: models.LoginPlain,
|
||||||
|
}
|
||||||
|
if form.MustChangePassword != nil {
|
||||||
|
u.MustChangePassword = *form.MustChangePassword
|
||||||
}
|
}
|
||||||
|
|
||||||
parseLoginSource(ctx, u, form.SourceID, form.LoginName)
|
parseLoginSource(ctx, u, form.SourceID, form.LoginName)
|
||||||
|
@ -135,6 +139,10 @@ func EditUser(ctx *context.APIContext, form api.EditUserOption) {
|
||||||
u.HashPassword(form.Password)
|
u.HashPassword(form.Password)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if form.MustChangePassword != nil {
|
||||||
|
u.MustChangePassword = *form.MustChangePassword
|
||||||
|
}
|
||||||
|
|
||||||
u.LoginName = form.LoginName
|
u.LoginName = form.LoginName
|
||||||
u.FullName = form.FullName
|
u.FullName = form.FullName
|
||||||
u.Email = form.Email
|
u.Email = form.Email
|
||||||
|
|
4
vendor/code.gitea.io/sdk/gitea/admin_user.go
generated
vendored
4
vendor/code.gitea.io/sdk/gitea/admin_user.go
generated
vendored
|
@ -23,7 +23,7 @@ type CreateUserOption struct {
|
||||||
Email string `json:"email" binding:"Required;Email;MaxSize(254)"`
|
Email string `json:"email" binding:"Required;Email;MaxSize(254)"`
|
||||||
// required: true
|
// required: true
|
||||||
Password string `json:"password" binding:"Required;MaxSize(255)"`
|
Password string `json:"password" binding:"Required;MaxSize(255)"`
|
||||||
MustChangePassword bool `json:"must_change_password"`
|
MustChangePassword *bool `json:"must_change_password"`
|
||||||
SendNotify bool `json:"send_notify"`
|
SendNotify bool `json:"send_notify"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ type EditUserOption struct {
|
||||||
// swagger:strfmt email
|
// swagger:strfmt email
|
||||||
Email string `json:"email" binding:"Required;Email;MaxSize(254)"`
|
Email string `json:"email" binding:"Required;Email;MaxSize(254)"`
|
||||||
Password string `json:"password" binding:"MaxSize(255)"`
|
Password string `json:"password" binding:"MaxSize(255)"`
|
||||||
MustChangePassword bool `json:"must_change_password"`
|
MustChangePassword *bool `json:"must_change_password"`
|
||||||
Website string `json:"website" binding:"MaxSize(50)"`
|
Website string `json:"website" binding:"MaxSize(50)"`
|
||||||
Location string `json:"location" binding:"MaxSize(50)"`
|
Location string `json:"location" binding:"MaxSize(50)"`
|
||||||
Active *bool `json:"active"`
|
Active *bool `json:"active"`
|
||||||
|
|
Loading…
Reference in a new issue