Skip to content

Commit

Permalink
Update auth.js
Browse files Browse the repository at this point in the history
add a redirect rule to the middleware if the user has not verified their email
  • Loading branch information
rdehnhardt authored Oct 10, 2024
1 parent f0e467a commit 9f2a97c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/hooks/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ export const useAuth = ({ middleware, redirectIfAuthenticated } = {}) => {
useEffect(() => {
if (middleware === 'guest' && redirectIfAuthenticated && user)
router.push(redirectIfAuthenticated)

if (middleware === 'auth' && !user?.email_verified_at)
router.push('/verify-email')

if (
window.location.pathname === '/verify-email' &&
user?.email_verified_at
Expand Down

0 comments on commit 9f2a97c

Please sign in to comment.