SpoonX / aurelia-authentication

Authentication plugin for aurelia.
http://aurelia-authentication.spoonx.org
MIT License
90 stars 60 forks source link

Error after refreshing token #393

Closed gregoryagu closed 6 years ago

gregoryagu commented 6 years ago

I am trying to get the Refresh Token to work correctly. After refreshing a token successfully from the server, Aurelia-Auth processes it, but it throws this error:

aurelia-authentication.js?cca0:1087 Uncaught TypeError: _this8.authentication.updateAuthenticated is not a function

This is the method that is throwing it:

this.storageEventHandler = function (event) {
      if (event.key !== _this8.config.storageKey || event.newValue === event.oldValue) {
        return;
      }

      if (_this8.config.autoUpdateToken && _this8.authentication.getAccessToken() && _this8.authentication.getRefreshToken()) {
        _this8.authentication.updateAuthenticated(); //Error is here

        return;
      }

    ...
gregoryagu commented 6 years ago

Oddly, the error only occurs during the AutoRefresh. When calling update manually, it does not throw this error.

doktordirk commented 6 years ago

I think that error got fixed meanwhile. It.s just not published on npm yet. You could try getting it from github directly or wait just s little until it.s published on npm

doktordirk commented 6 years ago

@gregoryagu 3.8 is on npm now. Give it a try

gregoryagu commented 6 years ago

I updated to 3.8 using npm install.

However, I am getting an error when Aurelia initializes:

Unhandled rejection TypeError: Cannot read property 'origin' of undefined
    at Object.configure (webpack-internal:///aurelia-authentication:1729:38)
function configure(frameworkConfig, config) {
  if (!_aureliaPal.PLATFORM.location.origin) //Error Here

The debugger shows that PLATFORM is an object, but does not have a property called location.

gregoryagu commented 6 years ago

Have tried npm update but still same result.

doktordirk commented 6 years ago

hmm: https://aurelia.io/docs/api/pal/interface/Platform may there are forks? it uses aurelia-pal 1.8 to use PLATFORM.moduleName for webpack builds. but then, PLATFORM.location had been there for some time. at a loss atm

doktordirk commented 6 years ago

i tried again with my webpack build using chrome and edge and had no issues.

gregoryagu commented 6 years ago

Thank you. After wiping and re-installing node_modules, all good.