From e53d12c2194c2e1b38883589d91ce901d08f4b51 Mon Sep 17 00:00:00 2001 From: Akanksh Saxena Date: Wed, 19 Aug 2020 16:16:25 +0200 Subject: [PATCH] fix(auth): Redirect to SSO if authentication fails --- app/protected/route.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/protected/route.js b/app/protected/route.js index d38b7636f..f78b93998 100644 --- a/app/protected/route.js +++ b/app/protected/route.js @@ -25,14 +25,20 @@ export default Route.extend(AuthenticatedRouteMixin, { media: service("media"), store: service(), ajax: service(), + router: service(), async model() { - const user = await this.ajax.request("/api/v1/users/me", { - method: "GET", - data: { - include: "supervisors,supervisees" - } - }); + let user; + try { + user = await this.ajax.request("/api/v1/users/me", { + method: "GET", + data: { + include: "supervisors,supervisees" + } + }); + } catch (error) { + this.router.transitionTo("login"); + } await this.store.pushPayload("user", user);