diff options
author | FChannel <> | 2021-10-24 10:40:45 -0700 |
---|---|---|
committer | FChannel <> | 2022-06-19 12:53:29 -0700 |
commit | 48fefb76c0a908cc3fa00abc9c090ce3ac8cb560 (patch) | |
tree | a7a24aec9f43222949e1f004fd5cd8a247e5024e /session.go | |
parent | 65e79e6a743f447f320595dafec530212a568b9d (diff) |
gofiber conversion, index, board posts, board post hooked up
Diffstat (limited to 'session.go')
-rw-r--r-- | session.go | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -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 "", "" +} |