-
Notifications
You must be signed in to change notification settings - Fork 1
/
application.ts
34 lines (31 loc) · 1.06 KB
/
application.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { action } from '@ember/object';
import Route from '@ember/routing/route';
import RouterService from '@ember/routing/router-service';
import { service } from '@ember/service';
import SessionService from 'ember-simple-auth/services/session';
import { warn } from '@ember/debug';
import CurrentSessionService from 'frontend-data-monitoring/services/current-session';
export default class ApplicationRoute extends Route {
@service declare router: RouterService;
@service declare session: SessionService<any>;
@service declare currentSession: CurrentSessionService;
async beforeModel() {
await this.session.setup();
return this._loadCurrentSession();
}
async _loadCurrentSession() {
try {
await this.currentSession.load();
} catch (error) {
console.error(error);
warn(error as string, { id: 'current-session-load-failure' });
this.router.transitionTo('auth.logout');
}
}
@action
error(error: Error) {
console.error('Error in application route:', error);
this.router.transitionTo('error');
return true;
}
}