Files
twenty/front/src/pages/auth/Verify.tsx
Jérémy M c6708b2c1f feat: rewrite auth (#364)
* feat: wip rewrite auth

* feat: restructure folders and fix stories and tests

* feat: remove auth provider and fix tests
2023-06-23 08:49:50 -07:00

34 lines
776 B
TypeScript

import { useEffect } from 'react';
import { useNavigate, useSearchParams } from 'react-router-dom';
import { useAuth } from '@/auth/hooks/useAuth';
import { useIsLogged } from '@/auth/hooks/useIsLogged';
export function Verify() {
const [searchParams] = useSearchParams();
const loginToken = searchParams.get('loginToken');
const isLogged = useIsLogged();
const navigate = useNavigate();
const { verify } = useAuth();
useEffect(() => {
async function getTokens() {
if (!loginToken) {
return;
}
await verify(loginToken);
navigate('/');
}
if (!isLogged) {
getTokens();
}
// Verify only needs to run once at mount
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return <></>;
}