ember.js - ember.run.later method not working inside custom authenticator -


i wrote custom token authenticator , have used local storage.

code explanation: in restore method, if token not empty , if expiresat greater current time have calculated wait time , set invalidate method executed after calculated wait time using ember.run.later.

problem: seems ember.run.later not working. after expiration time token persist in local storage. can send request , response after expiration time. after refreshing page, token destroyed in local storage , redirects login page. because restore method called on page reload?

but expected behavior is, token should automatically destroyed in local storage after expiration time (without page reload) , redirects login page.

as beginner may misunderstood concepts. correct me if wrong.

authenticators/custom.js

restore(data) {     let token, tokendata;     const dataobject = ember.object.create(data);     return new ember.rsvp.promise((resolve, reject) => {         const = math.floor((new date()).gettime() / 1000);         token = dataobject.get('token');         if (ember.isempty(token)) {             reject();         }         else {             tokendata = this.gettokendata(token);             const expiresat = tokendata['exp'];             if (expiresat > now) {                 const wait = ( expiresat - ) * 1000;                 ember.run.later(this, this.invalidate(data), wait);//not working                 resolve(data);             }             else {                 reject();             }         }     }); } 


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -