From 493fc8e025fd613d9faf0b573d610e4a0e0c0228 Mon Sep 17 00:00:00 2001
From: FChannel <>
Date: Tue, 3 May 2022 22:42:24 -0700
Subject: creating boards works

---
 db/verification.go | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

(limited to 'db')

diff --git a/db/verification.go b/db/verification.go
index c11e392..562503d 100644
--- a/db/verification.go
+++ b/db/verification.go
@@ -6,11 +6,13 @@ import (
 	"net/smtp"
 	"os"
 	"os/exec"
+	"strings"
 	"time"
 
 	"github.com/FChannel0/FChannel-Server/activitypub"
 	"github.com/FChannel0/FChannel-Server/config"
 	"github.com/FChannel0/FChannel-Server/util"
+	"github.com/gofiber/fiber/v2"
 	_ "github.com/lib/pq"
 )
 
@@ -487,3 +489,35 @@ func Captcha() string {
 
 	return newID
 }
+
+func HasValidation(ctx *fiber.Ctx, actor activitypub.Actor) bool {
+	id, _ := GetPassword(ctx)
+
+	if id == "" || (id != actor.Id && id != config.Domain) {
+		//http.Redirect(w, r, "/", http.StatusSeeOther)
+		return false
+	}
+
+	return true
+}
+
+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 "", ""
+}
-- 
cgit v1.2.3