mirror of
https://github.com/m1k1o/neko.git
synced 2025-06-02 10:52:41 +02:00
clear cookie if non-existent session.
This commit is contained in:
parent
da1d073846
commit
bf6181764b
4 changed files with 13 additions and 16 deletions
|
@ -25,20 +25,15 @@ func (manager *SessionManagerCtx) CookieSetToken(w http.ResponseWriter, token st
|
|||
})
|
||||
}
|
||||
|
||||
func (manager *SessionManagerCtx) CookieClearToken(w http.ResponseWriter) {
|
||||
sameSite := http.SameSiteDefaultMode
|
||||
if manager.config.CookieSecure {
|
||||
sameSite = http.SameSiteNoneMode
|
||||
func (manager *SessionManagerCtx) CookieClearToken(w http.ResponseWriter, r *http.Request) {
|
||||
cookie, err := r.Cookie(manager.config.CookieName)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
http.SetCookie(w, &http.Cookie{
|
||||
Name: manager.config.CookieName,
|
||||
Value: "",
|
||||
Expires: time.Unix(0, 0),
|
||||
Secure: manager.config.CookieSecure,
|
||||
SameSite: sameSite,
|
||||
HttpOnly: true,
|
||||
})
|
||||
cookie.Value = ""
|
||||
cookie.Expires = time.Unix(0, 0)
|
||||
http.SetCookie(w, cookie)
|
||||
}
|
||||
|
||||
func (manager *SessionManagerCtx) Authenticate(r *http.Request) (types.Session, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue