File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,15 @@ func New() func(http.Handler) http.Handler {
7979 }
8080}
8181
82+ func newToken (ctx context.Context , signer * securecookie.SecureCookie ) (string , error ) {
83+ encoded , err := signer .Encode (CookiesName , cookieValue {UserID : session .GetSession (ctx ).UserID })
84+ if err != nil {
85+ return "" , err
86+ }
87+
88+ return encoded , nil
89+ }
90+
8291func Verify (r * http.Request , formValue string ) bool {
8392 signer := r .Context ().Value (signerKey ).(* securecookie.SecureCookie )
8493 cookieToken := r .Context ().Value (tokenKey ).(string )
@@ -96,10 +105,15 @@ func Verify(r *http.Request, formValue string) bool {
96105 return v .UserID == session .GetSession (r .Context ()).UserID
97106}
98107
99- func Clear (w http.ResponseWriter ) {
108+ func Clear (w http.ResponseWriter , r * http.Request ) {
109+ token , err := newToken (r .Context (), r .Context ().Value (signerKey ).(* securecookie.SecureCookie ))
110+ if err != nil {
111+ panic ("failed to encode new token" )
112+ }
113+
100114 http .SetCookie (w , & http.Cookie {
101115 Name : CookiesName ,
102- Value : "" ,
116+ Value : token ,
103117 Path : "/" ,
104118 Secure : true ,
105119 HttpOnly : true ,
You can’t perform that action at this time.
0 commit comments