From a52199a894de352107c90defde93096a974fcd69 Mon Sep 17 00:00:00 2001 From: Shubhrajyoti Dey Date: Tue, 6 Feb 2024 23:35:05 +0530 Subject: [PATCH] Trying to fix fiber middleware --- handler/fiber-middleware.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/handler/fiber-middleware.go b/handler/fiber-middleware.go index 3f51754..e20ced2 100644 --- a/handler/fiber-middleware.go +++ b/handler/fiber-middleware.go @@ -2,6 +2,7 @@ package handler import ( "errors" + "net/http" "github.com/FrosTiK-SD/auth/constants" "github.com/FrosTiK-SD/auth/interfaces" @@ -12,6 +13,7 @@ import ( // For Gin based middlewares func (h *Handler) FiberVerifyStudent(ctx *fiber.Ctx) error { + token := ctx.Get("token", "") // Create a new session currentHandler := Handler{ @@ -23,7 +25,13 @@ func (h *Handler) FiberVerifyStudent(ctx *fiber.Ctx) error { }, } - context := gin.Context{} + context := gin.Context{ + Request: &http.Request{ + Header: http.Header{ + "token": []string{token}, + }, + }, + } currentHandler.HandlerVerifyStudentIdToken(&context) student := currentHandler.Session.Student