umstellung auf Service und Repository Verwendung - WIP
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
This commit is contained in:
+14
-1
@@ -1,7 +1,8 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"kontor-api-gin/pkg/globals"
|
||||
"kontor-api-gin/internal/globals"
|
||||
"kontor-api-gin/internal/helpers"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-contrib/sessions"
|
||||
@@ -22,3 +23,15 @@ func AuthRequired(c *gin.Context) {
|
||||
}
|
||||
c.Next()
|
||||
}
|
||||
|
||||
func JwtRequired(c *gin.Context) {
|
||||
logger := slog.Get(c)
|
||||
err := helpers.TokenValid(c)
|
||||
logger.Info("JwtRequired", "TokenValid", err)
|
||||
if err != nil {
|
||||
c.String(http.StatusUnauthorized, "Unauthorized")
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
c.Next()
|
||||
}
|
||||
Reference in New Issue
Block a user