From 80c513265e369a87edbbdb51c2d92588d038994d Mon Sep 17 00:00:00 2001 From: Stephanie Gredell Date: Sat, 2 Nov 2024 19:31:31 -0700 Subject: [PATCH] add a util file to host random methods that don't fit anywhere else --- utils/util.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 utils/util.go diff --git a/utils/util.go b/utils/util.go new file mode 100644 index 0000000..c61c22b --- /dev/null +++ b/utils/util.go @@ -0,0 +1,12 @@ +package utils + +import "github.com/gin-gonic/gin" + +func CheckIfLoggedIn(c *gin.Context) bool { + userID, err := c.Cookie("user_id") + if err != nil || userID == "" { + return false + } + + return true +}