dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit fa4f263c414143e562a8cec61888cc4df860e9fa
parent 21f81b8abdfa0e5cf8b6d942a263fc34751d3ec8
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Sat,  3 Dec 2022 23:06:29 -0500

cleanup

Diffstat:
Mpkg/web/handlers/handlers.go | 58+++++++++-------------------------------------------------
1 file changed, 9 insertions(+), 49 deletions(-)

diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go @@ -575,68 +575,28 @@ func LogoutHandler(ctx echo.Context) error { } func createPartialRecoveryCookie(value string, maxAge int64) *http.Cookie { - cookie := &http.Cookie{ - Name: "partial-recovery-token", - Value: value, - Domain: config.Global.CookieDomain(), - Secure: config.Global.CookieSecure(), - Path: "/", - HttpOnly: true, - MaxAge: int(maxAge), - SameSite: http.SameSiteLaxMode, - Expires: time.Now().Add(time.Duration(maxAge) * time.Second), - } - return cookie + return createCookie("partial-recovery-token", value, maxAge) } func createPartialRecovery2Cookie(value string, maxAge int64) *http.Cookie { - cookie := &http.Cookie{ - Name: "partial-recovery2-token", - Value: value, - Domain: config.Global.CookieDomain(), - Secure: config.Global.CookieSecure(), - Path: "/", - HttpOnly: true, - MaxAge: int(maxAge), - SameSite: http.SameSiteLaxMode, - Expires: time.Now().Add(time.Duration(maxAge) * time.Second), - } - return cookie + return createCookie("partial-recovery2-token", value, maxAge) } func createPartialSessionCookie(value string, maxAge int64) *http.Cookie { - cookie := &http.Cookie{ - Name: "partial-auth-token", - Value: value, - Domain: config.Global.CookieDomain(), - Secure: config.Global.CookieSecure(), - Path: "/", - HttpOnly: true, - MaxAge: int(maxAge), - SameSite: http.SameSiteLaxMode, - Expires: time.Now().Add(time.Duration(maxAge) * time.Second), - } - return cookie + return createCookie("partial-auth-token", value, maxAge) } func createSessionCookie(value string, maxAge int64) *http.Cookie { - cookie := &http.Cookie{ - Name: "auth-token", - Value: value, - Domain: config.Global.CookieDomain(), - Secure: config.Global.CookieSecure(), - Path: "/", - HttpOnly: true, - MaxAge: int(maxAge), - SameSite: http.SameSiteLaxMode, - Expires: time.Now().Add(time.Duration(maxAge) * time.Second), - } - return cookie + return createCookie("auth-token", value, maxAge) } func createSignupCookie(value string, maxAge int64) *http.Cookie { + return createCookie("signup-token", value, maxAge) +} + +func createCookie(name, value string, maxAge int64) *http.Cookie { cookie := &http.Cookie{ - Name: "signup-token", + Name: name, Value: value, Domain: config.Global.CookieDomain(), Secure: config.Global.CookieSecure(),