From 48fefb76c0a908cc3fa00abc9c090ce3ac8cb560 Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Sun, 24 Oct 2021 10:40:45 -0700 Subject: gofiber conversion, index, board posts, board post hooked up --- session.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'session.go') diff --git a/session.go b/session.go index 99ab1c2..b2af357 100644 --- a/session.go +++ b/session.go @@ -3,6 +3,7 @@ package main import ( "bufio" "fmt" + "github.com/gofiber/fiber/v2" "github.com/gomodule/redigo/redis" "net/http" "os" @@ -91,3 +92,26 @@ func GetPasswordFromSession(r *http.Request) (string, string) { return "", "" } + +func GetPasswordFromCtx(r *fiber.Ctx) (string, string) { + + c := r.Cookies("session_token") + + sessionToken := c + + response, err := cache.Do("GET", sessionToken) + + if CheckError(err, "could not get session from cache") != nil { + return "", "" + } + + token := fmt.Sprintf("%s", response) + + parts := strings.Split(token, "|") + + if len(parts) > 1 { + return parts[0], parts[1] + } + + return "", "" +} -- cgit v1.2.3