package domain

import (
	"github.com/gin-gonic/gin"
	"github.com/golang-jwt/jwt/v5"
	domainAuth "github.com/haydenhargreaves/Potion/internal/domain/auth"
	domainRecipe "github.com/haydenhargreaves/Potion/internal/domain/recipe"
	domainUser "github.com/haydenhargreaves/Potion/internal/domain/user"
)

type InjectedDependencies struct {
	UserService   domainUser.UserService
	AuthService   domainAuth.AuthService
	RecipeService domainRecipe.RecipeService
}

type JwtClaims struct {
	UserId int    `json:"id"`
	Email  string `json:"email"`
	jwt.RegisteredClaims
}

// IsLoggedIn checks the cookies in a request and returns whether the user is logged in.
func IsLoggedIn(ctx *gin.Context) bool {
	_, id := ctx.Get("userId")
	_, email := ctx.Get("userEmail")
	return id && email
}
