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

Auth service no removing cookies ( Angular 2 ) #316

Closed
2 of 6 tasks
Eslem opened this issue Jan 14, 2017 · 3 comments · Fixed by #336
Closed
2 of 6 tasks

Auth service no removing cookies ( Angular 2 ) #316

Eslem opened this issue Jan 14, 2017 · 3 comments · Fixed by #336

Comments

@Eslem
Copy link

Eslem commented Jan 14, 2017

What type of issue are you creating?

  • Bug
  • Enhancement
  • Question

What version of this module are you using?

  • 2.0.10 (Stable)
  • 2.1.0-rc.n (2.1 Release Candidate n)
  • Other

CookieBrowser service in some browsers (tested with ionic in android) the service is not removing all the cookies, so the session continue logued.
The problem is that in some browsers you have to add the path at the end of the expires. From w3school:

You should define the cookie path to ensure that you delete the right cookie.
Some browsers will not let you delete a cookie if you don't specify the path.

So the line 34 of the file cookie.browser.ts should be:
js document.cookie = key + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/;';

@Destreyf
Copy link
Contributor

Here's the code i'm using in my logout component (which also calls auth.clear)

window.document.cookie.split(";").forEach(function(c) { 
    document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/"); 
});

Its a little nasty but it removes everything (which is what we need in our project, not just sdk cookies).

@jonathan-casarrubias
Copy link
Collaborator

Hi @Eslem thanks for reporting, hey so I received a pull request fixing the path issue https://github.com/mean-expert-official/loopback-sdk-builder/pull/326/files

I'm about to bundle a new version with all the pull request and fixed and publish asap, maybe today maybe tomorrow

Cheers
Jon

@jonathan-casarrubias
Copy link
Collaborator

Also, there is going to be a new option to select either localStorage or cookies

jonathan-casarrubias pushed a commit that referenced this issue Jan 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants