Skip to content

Commit

Permalink
redirect teacher to otp form if pending
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Jun 14, 2024
1 parent 616bb6a commit d855e0f
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/pages/login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,26 @@ const Login: FC<LoginProps> = ({ form }) => {
)

useEffect(() => {
if (sessionMetadata && !sessionMetadata.auth_factors.length) {
navigate(
{
teacher: paths.teacher.dashboard.school._,
student: paths.student.dashboard._,
indy: paths.indy.dashboard._,
}[sessionMetadata.user_type],
{ replace: true },
)
if (sessionMetadata) {
if (
sessionMetadata.user_type === "teacher" &&
sessionMetadata.auth_factors.includes("otp") &&
form !== "teacher-otp" &&
form !== "teacher-otp-bypass-token"
) {
navigate(paths.login.teacher.otp._, { replace: true })
} else {
navigate(
{
teacher: paths.teacher.dashboard.school._,
student: paths.student.dashboard._,
indy: paths.indy.dashboard._,
}[sessionMetadata.user_type],
{ replace: true },
)
}
}
}, [sessionMetadata, navigate])
}, [sessionMetadata, navigate, form])

return (
<page.Page>
Expand Down

0 comments on commit d855e0f

Please sign in to comment.