Skip to content

Commit

Permalink
Merge pull request #4001 from serlo/quickfix-auth-error-page
Browse files Browse the repository at this point in the history
fix: use router inside useEffect
  • Loading branch information
elbotho authored Jul 29, 2024
2 parents 17edee5 + 379d442 commit 6838a0a
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions apps/web/src/pages/auth/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ function Error() {
const authStrings = useInstanceData().strings.auth

useEffect(() => {
if (
hasFlowErrorFieldError(error) &&
error.error.message.includes('ERR_BAD_ROLE')
) {
showToastNotice(authStrings.badRole, 'warning', 5000)
void router.push(loginUrl)
return
}

if (isProduction && error) {
triggerSentry({ message: 'Auth error in error flow', data: error })
showToastNotice(authStrings.somethingWrong, 'warning', 5000)
void router.push(loginUrl)
return
}

if (!router.isReady || error) return

kratos
Expand All @@ -46,23 +62,7 @@ function Error() {

return Promise.reject(err)
})
}, [id, router, router.isReady, error])

if (
hasFlowErrorFieldError(error) &&
error.error.message.includes('ERR_BAD_ROLE')
) {
showToastNotice(authStrings.badRole, 'warning', 5000)
void router.push(loginUrl)
return
}

if (isProduction) {
triggerSentry({ message: 'Auth error in error flow', data: error })
showToastNotice(authStrings.somethingWrong, 'warning', 5000)
void router.push(loginUrl)
return
}
}, [id, router, error, authStrings])

return error ? <pre>{JSON.stringify(error, null, 2)}</pre> : null
}
Expand Down

0 comments on commit 6838a0a

Please sign in to comment.