initial commit
This commit is contained in:
23
app/services/current-session.js
Normal file
23
app/services/current-session.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import Service, { service } from '@ember/service';
|
||||
import { tracked } from '@glimmer/tracking';
|
||||
|
||||
export default class CurrentSessionService extends Service {
|
||||
@service session;
|
||||
@service store;
|
||||
|
||||
@tracked account;
|
||||
|
||||
get user() {
|
||||
return this.account?.belongsTo('gebruiker').value();
|
||||
}
|
||||
|
||||
async load() {
|
||||
if (this.session.isAuthenticated) {
|
||||
const accountId =
|
||||
this.session.data.authenticated.relationships.account.data.id;
|
||||
this.account = await this.store.findRecord('account', accountId, {
|
||||
include: 'gebruiker',
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user