mirror of
https://github.com/goharbor/harbor
synced 2024-09-21 11:48:35 +00:00
Merge pull request #9252 from ywk253100/190925_sql
Make the username required when searching user
This commit is contained in:
commit
3b75ff8a4d
|
@ -774,20 +774,15 @@ paths:
|
||||||
description: Internal errors.
|
description: Internal errors.
|
||||||
/users/search:
|
/users/search:
|
||||||
get:
|
get:
|
||||||
summary: Search users by username, email
|
summary: Search users by username
|
||||||
description: |
|
description: |
|
||||||
This endpoint is to search the users by username, email.
|
This endpoint is to search the users by username.
|
||||||
parameters:
|
parameters:
|
||||||
- name: username
|
- name: username
|
||||||
in: query
|
in: query
|
||||||
type: string
|
type: string
|
||||||
required: false
|
required: true
|
||||||
description: Username for filtering results.
|
description: Username for filtering results.
|
||||||
- name: email
|
|
||||||
in: query
|
|
||||||
type: string
|
|
||||||
required: false
|
|
||||||
description: Email for filtering results.
|
|
||||||
- name: page
|
- name: page
|
||||||
in: query
|
in: query
|
||||||
type: integer
|
type: integer
|
||||||
|
|
|
@ -222,12 +222,15 @@ func (ua *UserAPI) Search() {
|
||||||
}
|
}
|
||||||
query := &models.UserQuery{
|
query := &models.UserQuery{
|
||||||
Username: ua.GetString("username"),
|
Username: ua.GetString("username"),
|
||||||
Email: ua.GetString("email"),
|
|
||||||
Pagination: &models.Pagination{
|
Pagination: &models.Pagination{
|
||||||
Page: page,
|
Page: page,
|
||||||
Size: size,
|
Size: size,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
if len(query.Username) == 0 {
|
||||||
|
ua.SendBadRequestError(errors.New("username is required"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
total, err := dao.GetTotalOfUsers(query)
|
total, err := dao.GetTotalOfUsers(query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user