Fix cookie weirdness (delete correctly using MaxAge)

This commit is contained in:
Daniel Ponte 2024-11-25 12:57:59 -05:00
parent 18e07e322f
commit 9b3743e79a
2 changed files with 7 additions and 4 deletions

View file

@ -156,6 +156,7 @@ func (a *Auth) routeRefresh(w http.ResponseWriter, r *http.Request) {
cookie := &http.Cookie{
Name: "jwt",
Value: tok,
Path: "/",
HttpOnly: true,
Secure: true,
}
@ -216,6 +217,7 @@ func (a *Auth) routeAuth(w http.ResponseWriter, r *http.Request) {
cookie := &http.Cookie{
Name: "jwt",
Value: tok,
Path: "/",
HttpOnly: true,
Secure: true,
}
@ -242,9 +244,10 @@ func (a *Auth) routeLogout(w http.ResponseWriter, r *http.Request) {
cookie := &http.Cookie{
Name: "jwt",
Value: "",
Path: "/",
HttpOnly: true,
Secure: true,
Expires: time.Time{},
MaxAge: -1,
}
if a.allowInsecureCookie(r) {

View file

@ -43,8 +43,8 @@ var ErrBadTG = errors.New("bad talkgroup format")
func (tid *ID) UnmarshalJSON(j []byte) error {
// this is a dirty hack since we cannot implement both TextUnmarshaler
// and json.Unmarshaler at the same time. sigh.
v := &struct{
System uint32 `json:"sys"`
v := &struct {
System uint32 `json:"sys"`
Talkgroup uint32 `json:"tg"`
}{}