aboutsummaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorFChannel <>2022-05-03 22:42:24 -0700
committerFChannel <>2022-06-19 12:53:29 -0700
commit493fc8e025fd613d9faf0b573d610e4a0e0c0228 (patch)
treefd7f217ca407c1aa8e584db26d0a95944c23b034 /db
parent328c9150228156c04d1045469c7dbcd7b5f4fedf (diff)
creating boards works
Diffstat (limited to 'db')
-rw-r--r--db/verification.go34
1 files changed, 34 insertions, 0 deletions
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 "", ""
+}