Make the username required when searching user

Make the username required when searching user and remove the support for query email

Signed-off-by: Wenkai Yin <yinw@vmware.com>
This commit is contained in:
Wenkai Yin 2019-09-25 13:32:29 +08:00
parent 360334991e
commit 83e7213d18
2 changed files with 7 additions and 9 deletions

View File

@ -774,20 +774,15 @@ paths:
description: Internal errors.
/users/search:
get:
summary: Search users by username, email
summary: Search users by username
description: |
This endpoint is to search the users by username, email.
This endpoint is to search the users by username.
parameters:
- name: username
in: query
type: string
required: false
required: true
description: Username for filtering results.
- name: email
in: query
type: string
required: false
description: Email for filtering results.
- name: page
in: query
type: integer

View File

@ -222,12 +222,15 @@ func (ua *UserAPI) Search() {
}
query := &models.UserQuery{
Username: ua.GetString("username"),
Email: ua.GetString("email"),
Pagination: &models.Pagination{
Page: page,
Size: size,
},
}
if len(query.Username) == 0 {
ua.SendBadRequestError(errors.New("username is required"))
return
}
total, err := dao.GetTotalOfUsers(query)
if err != nil {