Restrict the cookie to the /adm and /sec paths appropriately

This commit is contained in:
🐙PiperYxzzy
2022-05-01 13:37:01 +02:00
parent 0af09dcc01
commit 5903d52755

View File

@@ -24,8 +24,6 @@ type signup struct {
} }
const JwtHeader = "jwt" const JwtHeader = "jwt"
const ServicePath = "TODOPATH"
const ServiceDomain = "TODODOMAIN"
func UserSignup() gin.HandlerFunc { func UserSignup() gin.HandlerFunc {
return func(c *gin.Context) { return func(c *gin.Context) {
@@ -55,7 +53,7 @@ func UserSignup() gin.HandlerFunc {
} }
} else { } else {
// Send verification // Send verification
go util.SendEmail("Verify Email", "TODO: generate verification token", u.Email) go util.SendEmail("Verify Email", "TODO: generateverification token", u.Email)
} }
c.JSON(http.StatusOK, util.NextMsg{Next: "verification pending"}) c.JSON(http.StatusOK, util.NextMsg{Next: "verification pending"})
@@ -85,7 +83,7 @@ func UserLogin() gin.HandlerFunc {
} }
jwt, maxAge := u.GetJwt() jwt, maxAge := u.GetJwt()
c.SetCookie(JwtHeader, jwt, maxAge, ServicePath, ServiceDomain, true, true) c.SetCookie(JwtHeader, jwt, maxAge, "/v1/sec/", "", true, true)
} }
} }
@@ -117,7 +115,7 @@ func AdminLogin() gin.HandlerFunc {
} }
jwt, maxAge := a.GetJwt() jwt, maxAge := a.GetJwt()
c.SetCookie(JwtHeader, jwt, maxAge, ServicePath, ServiceDomain, true, true) c.SetCookie(JwtHeader, jwt, maxAge, "/v1/adm", "", true, true)
} }
} }