lynndylanhurley / ng-token-auth

Token based authentication module for angular.js.
Do What The F*ck You Want To Public License
1.8k stars 234 forks source link

Add support for Session Storage #244

Open MatthewVita opened 8 years ago

MatthewVita commented 8 years ago

As discussed here: https://github.com/lynndylanhurley/ng-token-auth/pull/240, sessionStorage is useful for scenarios where one doesn't want a session to persist between tabs/windows.

For example, some online banking implementations don't allow a user to log in and then reload the site in another window/tab for security reasons.

@booleanbetrayal suggests that we

implement an additive change for a convenience entry point for sessionStorage-backed persistence

From our discussion and my research I'm finding that the best defaults are cookies and localStorage. sessionStorage would be for specific use cases.

Tasks

lynndylanhurley commented 8 years ago

Hi @MatthewVita - you will only need a few steps to implement this:

  1. add a persistData method for sessionStorage here.
  2. add a retrieveData method here.
  3. add a deleteData method here.
  4. add an attempt to retrieve the saved config using sessionStorage here.

And I think that's it.

MatthewVita commented 8 years ago

@lynndylanhurley Awesome! Am going to plan out some time to work on this soon!

MatthewVita commented 8 years ago

@lynndylanhurley, @booleanbetrayal my (adds option for session storage) PR is here: https://github.com/lynndylanhurley/ng-token-auth/pull/247

I smoke tested it in the app I'm working on and it appears to be okay (the new unit test also passes). However, I was unable to run the localhost:7777 app because it points to what appears to be a Heroku instance for the backend.

Would one of you be able to do a code review and help me test this more exhaustively?

Thanks.