API /admin/users/{username} missing parameter (#4775)

This commit is contained in:
EnricoFerro
2018-08-24 01:59:47 +02:00
committed by techknowlogick
parent 127f477056
commit 912953e82a
5 changed files with 337 additions and 20 deletions

334
Gopkg.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -154,6 +154,12 @@ func EditUser(ctx *context.APIContext, form api.EditUserOption) {
if form.MaxRepoCreation != nil { if form.MaxRepoCreation != nil {
u.MaxRepoCreation = *form.MaxRepoCreation u.MaxRepoCreation = *form.MaxRepoCreation
} }
if form.AllowCreateOrganization != nil {
u.AllowCreateOrganization = *form.AllowCreateOrganization
}
if form.ProhibitLogin != nil {
u.ProhibitLogin = *form.ProhibitLogin
}
if err := models.UpdateUser(u); err != nil { if err := models.UpdateUser(u); err != nil {
if models.IsErrEmailAlreadyUsed(err) { if models.IsErrEmailAlreadyUsed(err) {

View File

@ -6496,6 +6496,10 @@
"type": "boolean", "type": "boolean",
"x-go-name": "Admin" "x-go-name": "Admin"
}, },
"allow_create_organization": {
"type": "boolean",
"x-go-name": "AllowCreateOrganization"
},
"allow_git_hook": { "allow_git_hook": {
"type": "boolean", "type": "boolean",
"x-go-name": "AllowGitHook" "x-go-name": "AllowGitHook"
@ -6530,6 +6534,10 @@
"type": "string", "type": "string",
"x-go-name": "Password" "x-go-name": "Password"
}, },
"prohibit_login": {
"type": "boolean",
"x-go-name": "ProhibitLogin"
},
"source_id": { "source_id": {
"type": "integer", "type": "integer",
"format": "int64", "format": "int64",

View File

@ -51,6 +51,8 @@ type EditUserOption struct {
AllowGitHook *bool `json:"allow_git_hook"` AllowGitHook *bool `json:"allow_git_hook"`
AllowImportLocal *bool `json:"allow_import_local"` AllowImportLocal *bool `json:"allow_import_local"`
MaxRepoCreation *int `json:"max_repo_creation"` MaxRepoCreation *int `json:"max_repo_creation"`
ProhibitLogin *bool `json:"prohibit_login"`
AllowCreateOrganization *bool `json:"allow_create_organization"`
} }
// AdminEditUser modify user informations // AdminEditUser modify user informations

View File

@ -42,3 +42,10 @@ func (c *Client) GetUserInfo(user string) (*User, error) {
err := c.getParsedResponse("GET", fmt.Sprintf("/users/%s", user), nil, nil, u) err := c.getParsedResponse("GET", fmt.Sprintf("/users/%s", user), nil, nil, u)
return u, err return u, err
} }
// GetMyUserInfo get user info of current user
func (c *Client) GetMyUserInfo() (*User, error) {
u := new(User)
err := c.getParsedResponse("GET", "/user", nil, nil, u)
return u, err
}