-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// auth.js (utility file) | ||
|
||
// Import the required libraries | ||
import axios from 'axios'; | ||
|
||
// Function to check if the user is authenticated based on the backend verification | ||
export async function isAuthenticated(token) { | ||
try { | ||
// make axios get request sending cookie. | ||
const response = await axios.get('http://localhost:5000/api/verify_user', { | ||
headers: { | ||
Authorization: 'Bearer ${token}', // Send the JWT token in the Authorization header | ||
}, | ||
}); | ||
|
||
return response.data.authenticated; | ||
} catch (error) { | ||
// console.error('Error during user verification:', error); | ||
return false; | ||
} | ||
} | ||
const AuthPage = () => { | ||
return ( | ||
<div> | ||
<h1>You shouldn't have gotten here!</h1> | ||
<p>This page is not meant to be accessed directly.</p> | ||
</div> | ||
); | ||
}; | ||
|
||
export default AuthPage; |