This commit is contained in:
ivamp 2024-12-10 18:45:46 +08:00
parent b15fa3f709
commit 6659671132
2 changed files with 7 additions and 9 deletions

View File

@ -50,6 +50,8 @@ func (a *Auth) Handler() fiber.Handler {
authorization := c.Get(constants.AuthHeader)
r.Status(http.StatusUnauthorized)
if authorization == "" {
return r.Error(errs.JWTFormatError).Send()
}
@ -66,11 +68,11 @@ func (a *Auth) Handler() fiber.Handler {
token, err = a.authService.AuthFromToken(constants.JwtTokenTypeIDToken, authSplit[1])
if err != nil {
return r.Error(err).Status(http.StatusUnauthorized).Send()
return r.Error(err).Send()
}
if token == nil {
return r.Error(err).Status(http.StatusUnauthorized).Send()
return r.Error(err).Send()
}
if audienceLength > 0 {

View File

@ -111,16 +111,12 @@ func (r *Response) Send() error {
var rspCtx = r.ctx.Status(r.httpStatus)
var rspErr error
if r.body.Data == nil {
return rspCtx.Send([]byte{})
}
if r.body.Wrap {
if r.body.Data == nil || r.body.Wrap {
rspErr = rspCtx.JSON(r.body)
} else {
rspErr = rspCtx.JSON(r.body.Data)
}
rspErr = rspCtx.JSON(r.body.Data)
return rspErr
}