From be40d7eae30d76d3439ec566beb9f846413b2900 Mon Sep 17 00:00:00 2001 From: proffapt Date: Sat, 29 Jun 2024 13:39:38 +0530 Subject: [PATCH] fix: check for heimdall token availability --- backend/main.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/main.go b/backend/main.go index 937462b..1a7653e 100644 --- a/backend/main.go +++ b/backend/main.go @@ -64,11 +64,11 @@ func PasswordGenerator(passwordLength int) string { } func register(res http.ResponseWriter, req *http.Request) { - cookie, _ := req.Cookie("heimdall") - // It won't throw any error. - // The service will be protected by heimdall - // Hence if this endpoint is being triggered then - // It means that cookie has to be present + cookie, err := req.Cookie("heimdall") + if err != nil { + http.Error(res, "No Heimdall session token received", http.StatusUnauthorized) + return + } tokenString := cookie.Value // Get email from JWT