-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
force user to verify email when using the application
- Loading branch information
1 parent
e4a79f1
commit c62e9ec
Showing
4 changed files
with
18 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ def create_admin_user(): | |
email="[email protected]", | ||
organization_id=1, | ||
role="admin", | ||
email_verified=True, | ||
) | ||
|
||
with DatabaseManager() as session: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ import { Navigate } from 'react-router-dom'; | |
import { useAuth } from '../../contexts/AuthContext'; | ||
|
||
function RequireAuth({ children }) { | ||
const { isAuthenticated, isLoading } = useAuth(); | ||
const { isAuthenticated, isLoading, isEmailVerified } = useAuth(); | ||
|
||
if (isLoading) { | ||
return <div>Loading...</div>; // Or your preferred loading indicator/component | ||
|
@@ -13,6 +13,11 @@ function RequireAuth({ children }) { | |
return <Navigate to="/login" />; | ||
} | ||
|
||
if (!isEmailVerified) { | ||
// Redirect to the verify-email page if email is not verified | ||
return <Navigate to="/verify-email" state={{ email: '[email protected]' }} />; | ||
} | ||
|
||
return children; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters