ENCOA-279

This commit is contained in:
Tiago Ribeiro
2024-12-12 15:06:00 +00:00
parent 3e74827c47
commit 240e36f15a
11 changed files with 71 additions and 73 deletions

View File

@@ -23,7 +23,7 @@ const EMAIL_REGEX = new RegExp(/^[a-zA-Z0-9]+(?:\.[a-zA-Z0-9]+)*@[a-zA-Z0-9]+(?:
export const getServerSideProps = withIronSessionSsr(async ({ req, res, query }) => {
const destination = !query.destination ? "/" : Buffer.from(query.destination as string, 'base64').toString()
const user = await requestUser(req, res)
if (user) return redirect(destination)
if (user && user.isVerified) return redirect(destination)
return {
props: { user: null, destination },
@@ -39,13 +39,10 @@ export default function Login({ destination = "/" }: { destination?: string }) {
const router = useRouter();
const isOfficialExamLogin = useMemo(() => destination.startsWith("/official-exam"), [destination])
const { user, mutateUser } = useUser({
redirectTo: destination,
redirectIfFound: true,
});
const { user, mutateUser } = useUser();
useEffect(() => {
if (user) router.push(destination);
if (user && user.isVerified) router.push(destination);
}, [router, user, destination]);
const forgotPassword = () => {
@@ -173,7 +170,7 @@ export default function Login({ destination = "/" }: { destination?: string }) {
</span>
</>
)}
{/* {user && !user.isVerified && <EmailVerification user={user} isLoading={isLoading} setIsLoading={setIsLoading} />} */}
{user && !user.isVerified && <EmailVerification user={user} isLoading={isLoading} setIsLoading={setIsLoading} />}
</section>
</main>
</>