Skip to content

Commit

Permalink
Merge pull request #25 from ARUNK2121/finalization
Browse files Browse the repository at this point in the history
token fix
  • Loading branch information
ARUNK2121 authored Nov 8, 2023
2 parents a8b7c63 + 2384b45 commit e085472
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/api/middleware/auth.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package middleware

import (
"fmt"
"strings"

"github.com/gin-gonic/gin"
"github.com/golang-jwt/jwt"
)
Expand All @@ -9,11 +12,14 @@ func AdminAuthMiddleware(c *gin.Context) {

accessToken := c.Request.Header.Get("Authorization")

accessToken = strings.TrimPrefix(accessToken, "Bearer ")

_, err := jwt.Parse(accessToken, func(token *jwt.Token) (interface{}, error) {
return []byte("accesssecret"), nil
})
if err != nil {
// The access token is invalid.
fmt.Println("error catches here")
c.AbortWithStatus(401)
return
}
Expand Down

0 comments on commit e085472

Please sign in to comment.