Hayden Hargreaves d2835c636c (DB/FEAT): Began the implementation of the user engagement!
The database requirements have been added, as well as the service/repo
architecture. A few small functions have been created, but the system is
not complete by any means. More work is required to mark this task
complete.
2025-07-13 21:34:54 -07:00

35 lines
1.2 KiB
Go

package domain
import (
"github.com/gin-gonic/gin"
"github.com/golang-jwt/jwt/v5"
domainAuth "github.com/haydenhargreaves/Potion/internal/domain/auth"
domainEngagement "github.com/haydenhargreaves/Potion/internal/domain/engagement"
domainRecipe "github.com/haydenhargreaves/Potion/internal/domain/recipe"
domainUser "github.com/haydenhargreaves/Potion/internal/domain/user"
)
// InjectedDependencies is a collection of dependencies that are injected into the application. They
// are stored in the context and can be accessed by handlers via the context.
type InjectedDependencies struct {
UserService domainUser.UserService
AuthService domainAuth.AuthService
RecipeService domainRecipe.RecipeService
EngagementService domainEngagement.EngagementService
}
// JwtClaims is the data stored in the JSON web token. All that is needed is the users ID and their
// Google email provided.
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
}