auth-module icon indicating copy to clipboard operation
auth-module copied to clipboard

options.token.name not used anymore

Open Sheby opened this issue 8 years ago • 6 comments

Version

4.0.1

Steps to reproduce

Set token.name to false.

Login using any strategy.

Token is still set in localStorage under key 'auth._token.local' or whatever other strategy is used.

What is expected ?

Token should not appear in localStorage.

What is actually happening?

Token is still set in local storage.

Additional comments?

I've just upgraded from 4.0.0-rc.3 to 4.0.1. In older version version I've set token.name to false since I'm using same auth in multiple nuxt projects. Lets say my cookie domain is '.example.com' and i have nuxt projects on 'admin.example.com' (d1) and 'store.example.com' (d2). If a user logs in on d1 cookies and local storage are set, and then if he goes to d2 he will be logged in automatically, which is desired. But if he then logs out either on d1 (or d2) and navigates to d2 (or d1) he will be logged in again since local storage was not cleared, at the same time new cookie will be set which is valid for both domains, and voila user is logged in on both domains again like he never logged out.

It looks to me all values are saved both in local storage and cookies, maybe you could provide an option to disable local storage completely?

This bug report is available on Nuxt.js community (#c87)

Sheby avatar Apr 05 '18 09:04 Sheby

It looks like you can no longer customize the name, but you can still disable certain universal storage techniques:

  • setCookie checks for falsey options.cookie, so instead of setting cookie.name to false, you should set cookie to false
  • setLocalStorage is similar, so in your case you should set localStorage to false.

Does that help?

benmccallum avatar Apr 10 '18 16:04 benmccallum

Looks like the docs are out of date, I'll update them when I get a sec

benmccallum avatar Apr 10 '18 16:04 benmccallum

It works, thanks. I somehow missed that while I was going trough source.

Edit: I'll open another issue for server side problem, close this once doc is update.

Sheby avatar Apr 11 '18 05:04 Sheby

Hey @Sheby, let me know how the documentation looks when changed in the above PR #135. 😃

benmccallum avatar Apr 11 '18 10:04 benmccallum

@benmccallum seems good. On different issue #133 , could you just add that if token.prefix starts with "_" local store won't work on server side.

Sheby avatar Apr 11 '18 10:04 Sheby

Sure thing, let's discuss that over there. The PR can treat both.

benmccallum avatar Apr 11 '18 11:04 benmccallum