feat: refac and add key deletion route
This commit is contained in:
@@ -42,7 +42,7 @@ func AuthMiddleware() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
authorizationHeader := c.GetHeader("Authorization")
|
||||
if len(authorizationHeader) == 0 {
|
||||
c.AbortWithStatusJSON(http.StatusUnauthorized, assets.BasicResponse{
|
||||
c.AbortWithStatusJSON(http.StatusUnauthorized, assets.ResponseObject{
|
||||
Msg: "Authorization header is required",
|
||||
})
|
||||
return
|
||||
@@ -52,7 +52,7 @@ func AuthMiddleware() gin.HandlerFunc {
|
||||
// The header must be a specific format, 0 being the bearer text and 1 being the token itself, making it 2 pieces total
|
||||
// In the following if statement we verify both parts if the part after Bearer is empty its only 1 part for example
|
||||
if len(headerParts) != 2 || headerParts[0] != "Bearer" {
|
||||
c.AbortWithStatusJSON(http.StatusUnauthorized, assets.BasicResponse{
|
||||
c.AbortWithStatusJSON(http.StatusUnauthorized, assets.ResponseObject{
|
||||
Msg: "Authorization header is invalid",
|
||||
})
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user