clear cookie if failing
This commit is contained in:
@@ -68,15 +68,27 @@ func (a *CheckoutPoolServer) reserveInventory(ctx context.Context, grain *checko
|
||||
const checkoutCookieName = "checkoutid"
|
||||
|
||||
func setCheckoutCookie(w http.ResponseWriter, checkoutId checkout.CheckoutId, tls bool) {
|
||||
http.SetCookie(w, &http.Cookie{
|
||||
Name: checkoutCookieName,
|
||||
Value: checkoutId.String(),
|
||||
Secure: tls,
|
||||
HttpOnly: true,
|
||||
Path: "/",
|
||||
Expires: time.Now().AddDate(0, 0, 14),
|
||||
SameSite: http.SameSiteLaxMode,
|
||||
})
|
||||
if checkoutId == 0 {
|
||||
http.SetCookie(w, &http.Cookie{
|
||||
Name: checkoutCookieName,
|
||||
Value: checkoutId.String(),
|
||||
Secure: tls,
|
||||
HttpOnly: true,
|
||||
Path: "/",
|
||||
Expires: time.Unix(0, 0),
|
||||
SameSite: http.SameSiteLaxMode,
|
||||
})
|
||||
} else {
|
||||
http.SetCookie(w, &http.Cookie{
|
||||
Name: checkoutCookieName,
|
||||
Value: checkoutId.String(),
|
||||
Secure: tls,
|
||||
HttpOnly: true,
|
||||
Path: "/",
|
||||
Expires: time.Now().AddDate(0, 0, 14),
|
||||
SameSite: http.SameSiteLaxMode,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func CookieCheckoutIdHandler(fn func(w http.ResponseWriter, r *http.Request, checkoutId checkout.CheckoutId) error) func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user