1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-08 23:15:29 +02:00
This commit is contained in:
zinyando 2016-06-27 14:47:48 +02:00
parent 69c760d351
commit 7cce377f93
2 changed files with 21 additions and 21 deletions

View file

@ -33,7 +33,7 @@ export default Ember.Service.extend({
} }
return this.get('ajax').request('public/meta') return this.get('ajax').request('public/meta')
.then((response) => { .then((response) => {
this.setProperties(response); this.setProperties(response);
}); });
} }

View file

@ -139,6 +139,26 @@ export default Ember.Service.extend({
// Application boot process // Application boot process
boot() { boot() {
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";
}
});
}
let self = this; let self = this;
let dbhash = ""; let dbhash = "";
@ -194,25 +214,5 @@ 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";
}
});
}
} }
}); });