mirror of
https://github.com/documize/community.git
synced 2025-08-09 07:25:23 +02:00
Update session.js
This commit is contained in:
parent
e25fb2dce5
commit
7e31b459b3
1 changed files with 20 additions and 0 deletions
|
@ -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";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue