Skip to content

Commit

Permalink
Update auth.js (#56)
Browse files Browse the repository at this point in the history
* Update auth.js

add a redirect rule to the middleware if the user has not verified their email

* Update auth.js

---------

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
rdehnhardt and taylorotwell authored Oct 10, 2024
1 parent f0e467a commit 98841a0
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 98841a0

Please sign in to comment.