forked from gitea/gitea
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
|
@ -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"
|
||||||
|
|
|
@ -60,9 +60,13 @@ func CreateUser(ctx *context.APIContext, form api.CreateUserOption) {
|
||||||
FullName: form.FullName,
|
FullName: form.FullName,
|
||||||
Email: form.Email,
|
Email: form.Email,
|
||||||
Passwd: form.Password,
|
Passwd: form.Password,
|
||||||
|
MustChangePassword: true,
|
||||||
IsActive: true,
|
IsActive: true,
|
||||||
LoginType: models.LoginPlain,
|
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)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
|
@ -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
|
||||||
|
|
|
@ -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 New Issue