fix: 🐛 gracefully handle missing user and/or target on sessions

This commit is contained in:
Randall Morey committed 2020-09-28 17:18:47 -04:00
1 parent 03cc063c81
commit 29ec96774e
2 files changed
+8 -3

No files matched your search

+2 -1
View File
@@ -6,6 +6,7 @@ import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import { later } from '@ember/runloop';
import loading from 'ember-loading/decorator';
import { A } from '@ember/array';
/**
* Entry route for the application.
@@ -81,7 +82,7 @@ export default class ApplicationRoute extends Route.extend(
*/
@action
error(e) {
const isUnauthenticated = e?.errors[0]?.isUnauthenticated;
const isUnauthenticated = A(e?.errors)?.firstObject?.isUnauthenticated;
if (isUnauthenticated) {
this.session.invalidate();
return false;
@@ -45,8 +45,12 @@ export default class ScopesScopeProjectsProjectSessionsRoute extends Route {
return all(
sessions.map(session => hash({
session,
user: this.store.findRecord('user', session.user_id),
target: this.store.findRecord('target', session.target_id),
user: session.user_id
? this.store.findRecord('user', session.user_id)
: null,
target: session.target_id
? this.store.findRecord('target', session.target_id)
: null,
}))
);
}