Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookie not deleted with LoginVerify #9

Open
efojs opened this issue Jul 31, 2021 · 1 comment
Open

Cookie not deleted with LoginVerify #9

efojs opened this issue Jul 31, 2021 · 1 comment

Comments

@efojs
Copy link

efojs commented Jul 31, 2021

Description

Debugging why cookie not deleted with LoginVerify if REQUIRE_SAME_BROWSER,
found that it is set properly:

set-cookie: 
magiclink498=e214549f-0d66-491a-a494-20964daa649e; 
Path=/

But for deletion, browser gets this:

set-cookie: 
magiclink498=""; 
expires=Thu, 01 Jan 1970 00:00:00 GMT; 
Max-Age=0; 
Path=e214549f-0d66-491a-a494-20964daa649e

Setting breakpoint after response.delete_cookie(cookie_name, magiclink.cookie_value) shows:

(Pdb) response.cookies.values()
dict_values([<Morsel: magiclink498=""; expires=Thu, 01 Jan 1970 00:00:00 GMT; Max-Age=0; Path=e214549f-0d66-491a-a494-20964daa649e>])

While after response.set_cookie(cookie_name, magiclink.cookie_value):

(Pdb) response.cookies.values()
dict_values([<Morsel: magiclink498=e214549f-0d66-491a-a494-20964daa649e; Path=/>])

Question

Do you have any ideas why can it happen?
Can you recreate it?

System

MagicLink: ==1.0.4
Django: ==3.2.5
Python: 3.8

@pyepye
Copy link
Owner

pyepye commented Sep 8, 2021

Hi @efojs

Sorry if I'm not getting this but it looks like it's working as expected?

It's up to the browser to delete a cookie but the cookie value is getting set to "" and it's being set to expire at Thu, 01 Jan 1970 00:00:00 GMT which is the server side way of setting a cookie to delete.

There is a test which ensures this is what happens on LoginVerify:
https://github.com/pyepye/django-magiclink/blob/master/tests/test_login_verify.py#L33-L34

Thanks
Matt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants