Skip to content

Commit

Permalink
Update response.go
Browse files Browse the repository at this point in the history
  • Loading branch information
laijinhang authored and cg33 committed Feb 15, 2022
1 parent a45d01e commit 62a5a5a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion plugins/admin/modules/response/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ func OkWithData(ctx *context.Context, data map[string]interface{}) {
}

func BadRequest(ctx *context.Context, msg string) {
user := ctx.UserValue["user"].(models.UserModel)
var user = models.UserModel{}
var ok bool
if user, ok = ctx.UserValue["user"].(models.UserModel); !ok {
user.Id = -1
}
ctx.JSON(http.StatusBadRequest, map[string]interface{}{
"code": http.StatusBadRequest,
"msg": language.GetUser(msg, user.Id),
Expand Down

0 comments on commit 62a5a5a

Please sign in to comment.