aboutsummaryrefslogtreecommitdiff
path: root/routes/util.go
diff options
context:
space:
mode:
Diffstat (limited to 'routes/util.go')
-rw-r--r--routes/util.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/routes/util.go b/routes/util.go
new file mode 100644
index 0000000..37639c3
--- /dev/null
+++ b/routes/util.go
@@ -0,0 +1,39 @@
+package routes
+
+import (
+ "fmt"
+ "strings"
+
+ "github.com/gofiber/fiber/v2"
+)
+
+func getThemeCookie(c *fiber.Ctx) string {
+ cookie := c.Cookies("theme")
+ if cookie != "" {
+ cookies := strings.SplitN(cookie, "=", 2)
+ return cookies[0]
+ }
+
+ return "default"
+}
+
+func getPassword(r *fiber.Ctx) (string, string) {
+ c := r.Cookies("session_token")
+
+ sessionToken := c
+
+ response, err := cache.Do("GET", sessionToken)
+ if err != nil {
+ return "", ""
+ }
+
+ token := fmt.Sprintf("%s", response)
+
+ parts := strings.Split(token, "|")
+
+ if len(parts) > 1 {
+ return parts[0], parts[1]
+ }
+
+ return "", ""
+}