Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit 542b78d

Browse files
author
Akanksh Saxena
authored
Merge pull request #471 from aziiee/login_redirect
fix(auth): Redirect to SSO if authentication fails
2 parents 324fcdd + e53d12c commit 542b78d

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

app/protected/route.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,20 @@ export default Route.extend(AuthenticatedRouteMixin, {
2525
media: service("media"),
2626
store: service(),
2727
ajax: service(),
28+
router: service(),
2829

2930
async model() {
30-
const user = await this.ajax.request("/api/v1/users/me", {
31-
method: "GET",
32-
data: {
33-
include: "supervisors,supervisees"
34-
}
35-
});
31+
let user;
32+
try {
33+
user = await this.ajax.request("/api/v1/users/me", {
34+
method: "GET",
35+
data: {
36+
include: "supervisors,supervisees"
37+
}
38+
});
39+
} catch (error) {
40+
this.router.transitionTo("login");
41+
}
3642

3743
await this.store.pushPayload("user", user);
3844

0 commit comments

Comments
 (0)