mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-30 00:00:13 +01:00

Add logout route as buffer between logged-in state and login form Fix setting current user in service Fix message on invalid credentials in login form Don't save the user password
30 lines
660 B
JavaScript
30 lines
660 B
JavaScript
import Ember from 'ember';
|
|
|
|
const {
|
|
inject: { service },
|
|
RSVP
|
|
} = Ember;
|
|
|
|
export default Ember.Service.extend({
|
|
session: service('session'),
|
|
store: service(),
|
|
|
|
loadCurrentUser() {
|
|
var _this = this;
|
|
|
|
return new RSVP.Promise((resolve, reject) => {
|
|
const token = this.get('session.data.authenticated.token');
|
|
if (!Ember.isEmpty(token)) {
|
|
return this.get('store').findRecord('user', 'me').then(function(user) {
|
|
_this.set('user', user);
|
|
resolve();
|
|
}, function() {
|
|
_this.get('session').invalidate();
|
|
reject();
|
|
});
|
|
} else {
|
|
resolve();
|
|
}
|
|
});
|
|
}
|
|
});
|