mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-26 20:26:13 +01:00
modify code according to review
This commit is contained in:
parent
e4bffb59da
commit
b29a41034c
@ -25,7 +25,10 @@ import (
|
|||||||
|
|
||||||
// Register is used for user to register, the password is encrypted before the record is inserted into database.
|
// Register is used for user to register, the password is encrypted before the record is inserted into database.
|
||||||
func Register(user models.User) (int64, error) {
|
func Register(user models.User) (int64, error) {
|
||||||
|
//when register from ldap, email may be empty
|
||||||
|
if user.Email == "" || len(user.Email) == 0 {
|
||||||
|
user.Email = user.Username + "@vmware.com"
|
||||||
|
}
|
||||||
o := GetOrmer()
|
o := GetOrmer()
|
||||||
p, err := o.Raw("insert into user (username, password, realname, email, comment, salt, sysadmin_flag, creation_time, update_time) values (?, ?, ?, ?, ?, ?, ?, ?, ?)").Prepare()
|
p, err := o.Raw("insert into user (username, password, realname, email, comment, salt, sysadmin_flag, creation_time, update_time) values (?, ?, ?, ?, ?, ?, ?, ?, ?)").Prepare()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -232,6 +232,10 @@ func DeleteUser(userID int) error {
|
|||||||
|
|
||||||
// ChangeUserProfile ...
|
// ChangeUserProfile ...
|
||||||
func ChangeUserProfile(user models.User) error {
|
func ChangeUserProfile(user models.User) error {
|
||||||
|
//email is null is permitted
|
||||||
|
if user.Email == "" || len(user.Email) == 0 {
|
||||||
|
user.Email = user.Username + "@vmware.com"
|
||||||
|
}
|
||||||
o := GetOrmer()
|
o := GetOrmer()
|
||||||
if _, err := o.Update(&user, "Email", "Realname", "Comment"); err != nil {
|
if _, err := o.Update(&user, "Email", "Realname", "Comment"); err != nil {
|
||||||
log.Errorf("update user failed, error: %v", err)
|
log.Errorf("update user failed, error: %v", err)
|
||||||
|
@ -119,7 +119,7 @@ paths:
|
|||||||
description: Project name already exists.
|
description: Project name already exists.
|
||||||
500:
|
500:
|
||||||
description: Unexpected internal errors.
|
description: Unexpected internal errors.
|
||||||
/projects/{project_id}/toggle_project_public:
|
/projects/{project_id}/publicity:
|
||||||
post:
|
post:
|
||||||
summary: Update properties for a selected project.
|
summary: Update properties for a selected project.
|
||||||
description: |
|
description: |
|
||||||
@ -444,6 +444,24 @@ paths:
|
|||||||
format: int32
|
format: int32
|
||||||
required: true
|
required: true
|
||||||
description: Registered user ID
|
description: Registered user ID
|
||||||
|
- name: email
|
||||||
|
in: body
|
||||||
|
type: string
|
||||||
|
format: string
|
||||||
|
required: false
|
||||||
|
description: Email of the user
|
||||||
|
- name: realname
|
||||||
|
in: body
|
||||||
|
type: string
|
||||||
|
format: string
|
||||||
|
required: true
|
||||||
|
description: Realname of the user
|
||||||
|
- name: comment
|
||||||
|
in: body
|
||||||
|
type: string
|
||||||
|
format: string
|
||||||
|
required: false
|
||||||
|
description: Comment of the user
|
||||||
tags:
|
tags:
|
||||||
- Products
|
- Products
|
||||||
responses:
|
responses:
|
||||||
@ -517,7 +535,7 @@ paths:
|
|||||||
description: Guests can only change their own account.
|
description: Guests can only change their own account.
|
||||||
500:
|
500:
|
||||||
description: Unexpected internal errors.
|
description: Unexpected internal errors.
|
||||||
/users/{user_id}/toggle_user_admin:
|
/users/{user_id}/sysadmin:
|
||||||
post:
|
post:
|
||||||
summary: Update a registered user to change to be an administrator of Harbor.
|
summary: Update a registered user to change to be an administrator of Harbor.
|
||||||
description: |
|
description: |
|
||||||
|
@ -55,12 +55,12 @@ func initRouters() {
|
|||||||
beego.Router("/api/projects/:pid/members/?:mid", &api.ProjectMemberAPI{})
|
beego.Router("/api/projects/:pid/members/?:mid", &api.ProjectMemberAPI{})
|
||||||
beego.Router("/api/projects/", &api.ProjectAPI{}, "get:List")
|
beego.Router("/api/projects/", &api.ProjectAPI{}, "get:List")
|
||||||
beego.Router("/api/projects/?:id", &api.ProjectAPI{})
|
beego.Router("/api/projects/?:id", &api.ProjectAPI{})
|
||||||
beego.Router("/api/projects/:id/toggle_project_public", &api.ProjectAPI{}, "post:ToggleProjectPublic")
|
beego.Router("/api/projects/:id/publicity", &api.ProjectAPI{}, "post:ToggleProjectPublic")
|
||||||
beego.Router("/api/statistics", &api.StatisticAPI{})
|
beego.Router("/api/statistics", &api.StatisticAPI{})
|
||||||
beego.Router("/api/projects/:id/logs/filter", &api.ProjectAPI{}, "post:FilterAccessLog")
|
beego.Router("/api/projects/:id/logs/filter", &api.ProjectAPI{}, "post:FilterAccessLog")
|
||||||
beego.Router("/api/users/?:id", &api.UserAPI{})
|
beego.Router("/api/users/?:id", &api.UserAPI{})
|
||||||
beego.Router("/api/users/:id/password", &api.UserAPI{}, "put:ChangePassword")
|
beego.Router("/api/users/:id/password", &api.UserAPI{}, "put:ChangePassword")
|
||||||
beego.Router("/api/users/:id/toggle_user_admin", &api.UserAPI{}, "post:ToggleUserAdminRole")
|
beego.Router("/api/users/:id/sysadmin", &api.UserAPI{}, "post:ToggleUserAdminRole")
|
||||||
beego.Router("/api/repositories", &api.RepositoryAPI{})
|
beego.Router("/api/repositories", &api.RepositoryAPI{})
|
||||||
beego.Router("/api/repositories/tags", &api.RepositoryAPI{}, "get:GetTags")
|
beego.Router("/api/repositories/tags", &api.RepositoryAPI{}, "get:GetTags")
|
||||||
beego.Router("/api/repositories/manifests", &api.RepositoryAPI{}, "get:GetManifests")
|
beego.Router("/api/repositories/manifests", &api.RepositoryAPI{}, "get:GetManifests")
|
||||||
|
Loading…
Reference in New Issue
Block a user