0

I am using Angular Satellizer v0.15.x with bower in my Angular v1.6.4 app.

My exact workflow is as follows:

  1. User opens a page.
  2. The user clicks on a button.
  3. Google sign in popup opens using satallizer's $authenticate('google') method.
  4. User signs in.
  5. Satellizer receives google's auth code and sends it to my API
  6. API fetches user's auth and refresh tokens based on auth code, and stores it in DB. Responds to the Angular UI.
  7. AngularJS calls another method to save user's details.

I am using JWT token to make API calls as my API is stateless. I store this token in my local storage with the key app.auth.token. As soon as the 6th step completes of my workflow, my JWT token is removed from local storage (and the 7th step fails).

I suspected naming clashes, and tried to name my JWT token to something else, but no luck. I even analyzed all of my code, and I am not removing the token anywhere from my code.

For now, I've kept two copies of the JWT in local storage and I copy the token from the backup as soon as it is removed.

Anyone out there, who can guide me on solving this issue?

Edit 1:

Here are all the bower packages which I'm using:

"dependencies": {
    "angular-animate": "^1.6.4",
    "angular-sanitize": "^1.6.4",
    "angular-messages": "^1.6.4",
    "angular-ui-router": "^0.4.2",
    "angular-strap": "^2.3.x",
    "moment": "^2.18.x",
    "animate.css": "^3.5.x",
    "angular": "^1.6.4",
    "ng-lodash": "^0.5.x",
    "ng-focus-if": "^1.0.x",
    "ngclipboard": "^1.1.x",
    "angular-toastr": "^1.7.x",
    "bootstrap-sass": "^3.3.x",
    "angular-motion": "^0.4.x",
    "angular-drag-and-drop-lists": "^1.4.x",
    "angular-local-storage": "^0.5.x",
    "angular-md5": "^0.1.x",
    "angular-translate": "^2.15.x",
    "moment-timezone": "^0.5.x",
    "ment.io": "personal github URL",
    "ng-material-floating-button": "personal github URL",
    "angular-base64": "^2.0.x",
    "satellizer": "^0.15.x",
    "ng-jsoneditor": "personal github URL",
    "highlightjs": "^9.10.x",
    "angular-highlightjs": "^0.7.x",
    "codemirror": "^5.25.x",
    "angular-ui-codemirror": "^0.3.x",
    "angular-carousel": "personal github URL",
    "angular-cron-jobs": "^3.2.x",
    "angular-read-more": "^1.0.x",
    "angular-moment": "^1.0.1"
  }
31piy
  • 23,323
  • 6
  • 47
  • 67
  • Might help : Satellizer has its own function $auth.setToken(token) => https://stackoverflow.com/questions/44337295/satellizer-login-jwt-token-is-gone-when-page-refresh/44363332#44363332 – Sangwin Gawande Jun 06 '17 at 09:41
  • @SangwinGawande: Fair enough! But why does it remove my token, which I store as `app.auth.token` (or with any other name)? – 31piy Jun 06 '17 at 10:48
  • Have you tried with different key name? Check if token is being removed or all localstorage is getting reset. – Sangwin Gawande Jun 06 '17 at 10:59
  • @SangwinGawande: Tried renaming the token to something else. Only my token gets removed. All other keys persist. – 31piy Jun 06 '17 at 11:00
  • Browser never deletes local storage. There must be a code that is doing this. – Sangwin Gawande Jun 09 '17 at 12:21
  • @SangwinGawande - I know that very well. The issue is, I am very sure that my code isn't removing it. – 31piy Jun 09 '17 at 13:18

0 Answers0