From 72a0ba6d14eeab71f7045b9d0c73c9c68f757336 Mon Sep 17 00:00:00 2001 From: Smilinko <95704377+Smilinko@users.noreply.github.com> Date: Sat, 9 Dec 2023 11:31:11 +0100 Subject: [PATCH] added redirections after logging in or out (#253) * added redirections after logging in or out * added redirections after logging in or out --- .../PageLayout/Authentication/Authentication.tsx | 12 +++++++++++- src/components/PageLayout/LoginForm/LoginForm.tsx | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/components/PageLayout/Authentication/Authentication.tsx b/src/components/PageLayout/Authentication/Authentication.tsx index 97e72320..efe7b608 100644 --- a/src/components/PageLayout/Authentication/Authentication.tsx +++ b/src/components/PageLayout/Authentication/Authentication.tsx @@ -1,4 +1,5 @@ import Link from 'next/link' +import {useRouter} from 'next/router' import {FC, useState} from 'react' import {AuthContainer} from '@/utils/AuthContainer' @@ -18,6 +19,15 @@ export const Authentication: FC = () => { const {seminar} = useSeminarInfo() + const router = useRouter() + + const redirectLogout = () => { + logout() + if (router.asPath.endsWith('profil') || router.asPath.endsWith('profil/uprava')) { + router.push('/') + } + } + if (!isAuthed) { return ( <> @@ -38,7 +48,7 @@ export const Authentication: FC = () => { return (