1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-08 06:55:28 +02:00

Update session.js

This commit is contained in:
Harvey Kandola 2016-06-25 10:38:41 -07:00 committed by zinyando
parent e25fb2dce5
commit 7e31b459b3

View file

@ -194,5 +194,25 @@ export default Ember.Service.extend({
});
}
});
let token = this.getSessionItem('token');
// TODO: the rest should be done through ESA
if (is.not.undefined(token)) {
// We now validate current token
return this.get('ajax').request(`public/validate?token=${token}`, {
method: 'GET',
contentType: 'json'
}).then((user) => {
this.setSession(token, models.UserModel.create(user));
this.set('ready', true);
}).catch((reason) => {
if (netUtil.isAjaxAccessError(reason)) {
localStorage.clear();
window.location.href = "/auth/login";
}
});
}
}
});