Ajoutez des fichiers projet.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||
import { useAuth } from '../context/AuthContext';
|
||||
|
||||
const AuthCallback = (): JSX.Element => {
|
||||
const [searchParams] = useSearchParams();
|
||||
const { handleCallback } = useAuth();
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
const token = searchParams.get('token');
|
||||
const error = searchParams.get('error');
|
||||
|
||||
if (error) {
|
||||
navigate(`/login?error=${error}`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (token) {
|
||||
handleCallback(token);
|
||||
navigate('/dashboard', { replace: true });
|
||||
} else {
|
||||
navigate('/login?error=no_token');
|
||||
}
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
minHeight: '100vh',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
fontFamily: 'sans-serif',
|
||||
fontSize: '18px',
|
||||
color: '#f5f5dc',
|
||||
}}>
|
||||
⏳ Connexion en cours...
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default AuthCallback;
|
||||
Reference in New Issue
Block a user