Check whether user is nil in Prepare() of users API (#7507)

Signed-off-by: Daniel Jiang <jiangd@vmware.com>
This commit is contained in:
Daniel Jiang 2019-04-28 14:06:35 +08:00 committed by Wang Yan
parent 2a463016a9
commit 80176cc354

View File

@ -102,6 +102,12 @@ func (ua *UserAPI) Prepare() {
return
}
if user == nil {
log.Errorf("User with username %s does not exist in DB.", ua.SecurityCtx.GetUsername())
ua.SendInternalServerError(fmt.Errorf("user %s does not exist in DB", ua.SecurityCtx.GetUsername()))
return
}
ua.currentUserID = user.UserID
id := ua.Ctx.Input.Param(":id")
if id == "current" {