Skip to content

Commit 66c44b4

Browse files
committed
Handle authentication errors with a auth_error page as we do in Physics
1 parent 5e872a5 commit 66c44b4

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

src/app/components/navigation/IsaacApp.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import {AddGameboard} from "../handlers/AddGameboard";
5252
import "../../services/scrollManager";
5353
import "../../services/polyfills";
5454
import {isTest} from "../../services/constants";
55+
import {AuthError} from "../pages/AuthError";
5556

5657
export const IsaacApp = () => {
5758
// Redux state and dispatch
@@ -80,6 +81,7 @@ export const IsaacApp = () => {
8081
{/* Errors; these paths work but aren't really used */}
8182
<Route exact path={serverError ? undefined : "/error"} component={ServerError} />
8283
<Route exact path={goneAwayError ? undefined : "/error_stale"} component={SessionExpired} />
84+
<TrackedRoute exact path={"/auth_error"} component={AuthError} />
8385

8486
{/* Special case */}
8587
<TrackedRoute exact path="/questions/:questionId(_regression_test_)" component={segueEnvironment !== "PROD" || isTest ? Question : NotFound} />
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from "react";
2+
import {Link} from "react-router-dom";
3+
import {TitleAndBreadcrumb} from "../elements/TitleAndBreadcrumb";
4+
import * as RS from "reactstrap";
5+
6+
export const AuthError = ({location: {state: {errorMessage}}}: {location: {state: {errorMessage: string}}}) => {
7+
8+
return <RS.Container>
9+
<TitleAndBreadcrumb currentPageTitle="Authentication error" breadcrumbTitleOverride="Authentication error" />
10+
<RS.Row className="pt-4">
11+
<RS.Col md={{size: 8, offset: 2}}>
12+
<h3>
13+
{errorMessage}
14+
</h3>
15+
<p>
16+
An error occurred while attempting to log in.
17+
<br />
18+
You may want to return to the <Link to="/home"> home page</Link> and try again, {" "}
19+
check <Link to="/support/student/general#login_issues">this FAQ</Link>
20+
, or <Link to="/contact">contact us</Link> if this keeps happening.
21+
</p>
22+
</RS.Col>
23+
</RS.Row>
24+
</RS.Container>
25+
};

src/app/state/actions.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,9 @@ export const handleProviderCallback = (provider: AuthenticationProvider, paramet
293293
} else {
294294
history.push(nextPage);
295295
}
296-
} catch (e) {
297-
dispatch(showErrorToastIfNeeded("Login Failed", e));
296+
} catch (error) {
297+
history.push({pathname: "/auth_error", state: {errorMessage: isAxiosError(error) ? extractMessage(error) : API_REQUEST_FAILURE_MESSAGE}});
298+
dispatch(showErrorToastIfNeeded("Login Failed", error));
298299
}
299300
};
300301

0 commit comments

Comments
 (0)