mirror of
https://github.com/GrassrootsEconomics/cic-dw.git
synced 2025-02-08 12:57:37 +01:00
add: cookie defaults and nuxt init check route
This commit is contained in:
parent
8e2625a094
commit
723c8bc71c
@ -31,6 +31,7 @@ func InitAdminApi(e *echo.Echo, db *pgxpool.Pool, queries goyesql.Queries, metaC
|
|||||||
g.Use(api.dwCoreMiddleware)
|
g.Use(api.dwCoreMiddleware)
|
||||||
g.Use(api.verifyAuthMiddleware)
|
g.Use(api.verifyAuthMiddleware)
|
||||||
|
|
||||||
|
g.GET("/check", isLoggedIn)
|
||||||
g.GET("/meta-proxy/:address", handleMetaProxy)
|
g.GET("/meta-proxy/:address", handleMetaProxy)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,10 @@ type jwtClaims struct {
|
|||||||
jwt.StandardClaims
|
jwt.StandardClaims
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isLoggedIn(c echo.Context) error {
|
||||||
|
return c.String(http.StatusOK, "ok")
|
||||||
|
}
|
||||||
|
|
||||||
func sendLoginJwtCookie(c echo.Context) error {
|
func sendLoginJwtCookie(c echo.Context) error {
|
||||||
var (
|
var (
|
||||||
api = c.Get("api").(*api)
|
api = c.Get("api").(*api)
|
||||||
@ -55,11 +59,8 @@ func sendLoginJwtCookie(c echo.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cookie := new(http.Cookie)
|
cookie := cookieDefaults()
|
||||||
|
|
||||||
cookie.Name = "_ge_auth"
|
|
||||||
cookie.Value = tokenString
|
cookie.Value = tokenString
|
||||||
cookie.Path = "/"
|
|
||||||
cookie.Expires = expiration
|
cookie.Expires = expiration
|
||||||
|
|
||||||
c.SetCookie(cookie)
|
c.SetCookie(cookie)
|
||||||
@ -67,12 +68,21 @@ func sendLoginJwtCookie(c echo.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func sendLogoutCookie(c echo.Context) error {
|
func sendLogoutCookie(c echo.Context) error {
|
||||||
cookie := new(http.Cookie)
|
cookie := cookieDefaults()
|
||||||
|
cookie.MaxAge = -1
|
||||||
cookie.Name = "_ge_auth"
|
|
||||||
cookie.Value = ""
|
|
||||||
cookie.Expires = time.Now()
|
|
||||||
|
|
||||||
c.SetCookie(cookie)
|
c.SetCookie(cookie)
|
||||||
return c.String(http.StatusOK, "logout successful")
|
return c.String(http.StatusOK, "logout successful")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func cookieDefaults() *http.Cookie {
|
||||||
|
cookie := new(http.Cookie)
|
||||||
|
|
||||||
|
cookie.Name = "_ge_auth"
|
||||||
|
cookie.Path = "/"
|
||||||
|
cookie.SameSite = 3
|
||||||
|
cookie.HttpOnly = true
|
||||||
|
cookie.Secure = false
|
||||||
|
|
||||||
|
return cookie
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user