Skip to content

Commit

Permalink
Handle errors in feide auth
Browse files Browse the repository at this point in the history
  • Loading branch information
LudvigHz committed Jul 31, 2023
1 parent 9ea1f49 commit f3a0ad3
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions app/routes/users/components/StudentConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Card from 'app/components/Card';
import { Button } from 'app/components/Form';
import { Container, Flex } from 'app/components/Layout';
import Modal from 'app/components/Modal';
import { HttpError } from 'app/utils/fetchJSON';
import styles from './UserConfirmation.css';

type Props = {
Expand Down Expand Up @@ -70,8 +71,12 @@ const StudentConfirmation = ({
useEffect(() => {
const validateStudentAuth = async () => {
if (code && state) {
const res = await confirmStudentAuth({ code, state });
setAuthRes(res.payload);
try {
const res = await confirmStudentAuth({ code, state });
setAuthRes(res.payload);
} catch (e) {
setAuthRes(e.payload.response.jsonData);
}
history.replace({ search: '' });
}
};
Expand Down Expand Up @@ -128,7 +133,7 @@ const StudentConfirmation = ({
</Card>
))}

{authRes && !isStudent && (
{authRes && authRes.status !== 'success' && (
<Card danger={authRes.status !== 'success'}>
{authRes.status === 'unauthorized' && (
<>
Expand All @@ -143,6 +148,12 @@ const StudentConfirmation = ({
<NotEligibleInfo />
</>
)}
{authRes.status === 'error' && (
<>
<h4>En feil oppsto under validering av din studentstatus:</h4>
<p>{authRes.detail}</p>
</>
)}
</Card>
)}

Expand Down

0 comments on commit f3a0ad3

Please sign in to comment.