Migrated from React to NextJS

This commit is contained in:
2022-10-14 13:58:57 +02:00
parent b2a16e5181
commit b4ff0c8f77
72 changed files with 1557 additions and 1686 deletions

View File

@@ -1,18 +1,22 @@
package middleware
import (
"twitch-clone/pkg/jwt"
"context"
"errors"
"twitch-clone/pkg/auth"
"github.com/gofiber/fiber/v2"
)
/*CheckToken : Check the validate of the jwt*/
func CheckToken(c *fiber.Ctx) error {
_, _, _, err := jwt.ProcessJWT(c.Get("Authorization"))
func CheckSession(c *fiber.Ctx) error {
cookie := c.Cookies("ory_kratos_session")
if cookie == "" {
return errors.New("no session found in cookie")
}
_, _, err := auth.AuthClient.V0alpha2Api.ToSession(context.Background()).Cookie(cookie).Execute()
if err != nil {
return err
}
c.Next()
return nil
}