Binary files /dev/null and b/public/images/dashboard.png differ @@ -319,7 +319,10 @@ const InfoBar: React.FC = ({ device }) => { signOut()} + onClick={() => { + signOut() + window.location.reload() + }} sx={{ marginTop: '15px', cursor: 'pointer' }} > {''} @@ -47,15 +47,9 @@ export const Layout: React.FC = ({ children, isAuthPage = false, titlePag const router = useRouter() React.useEffect(() => { - if (status === 'authenticated') { - dispatch(getUserBalance(data?.access)) - dispatch(getAllInfo(data?.access)) - } - - if (status === 'unauthenticated' && !freeRoutes.includes(router.route)) { - router.push('/login') - } - }, [status]) + dispatch(getUserBalance(data?.access)) + dispatch(getAllInfo(data?.access)) + }, [data]) React.useEffect(() => { if ( @@ -328,8 +328,8 @@ const Login: NextPageWithLayout = () => { width={42} height={42} /> - {/* {''} { border: '10px solid rgba(255, 255, 255, 0.30)', transform: 'rotate(-13deg)', }} - /> */} + /> )} @@ -177,8 +177,8 @@ const Register: NextPageWithLayout = () => { width={42} height={42} /> - {/* {''} { border: '10px solid rgba(255, 255, 255, 0.30)', transform: 'rotate(-13deg)', }} - /> */} + /> )} @@ -44,15 +44,9 @@ export const Layout: React.FC = ({ const router = useRouter() React.useEffect(() => { - if (status === 'authenticated') { - dispatch(getUserBalance(data?.access)) - dispatch(getAllInfo(data?.access)) - } - - if (status === 'unauthenticated' && !freeRoutes.includes(router.route)) { - router.push('/login') - } - }, [status]) + dispatch(getUserBalance(data?.access)) + dispatch(getAllInfo(data?.access)) + }, [data]) React.useEffect(() => { if ( @@ -13,29 +13,15 @@ export async function middleware(req: NextRequest) { const token = await getToken({ req }) if (!token && !pathname.startsWith('/login')) { - return redirectToLogin(req) + return NextResponse.redirect(new URL('/login', req.url)) + } else { + return NextResponse.next() } - - return NextResponse.next() -} - -function redirectToLogin(req: NextRequest) { - const url = req.nextUrl.clone() - url.pathname = '/login' - - const response = NextResponse.redirect(url) - - const queryParams = req.nextUrl.searchParams - - queryParams.forEach((value, key) => { - response.cookies.set(key, value) - }) - - return response } export const config = { matcher: [ - '/((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|svg|robots.txt|login|register|change-password|reset).*)', + '/((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|manifest.json|svg|robots.txt|login|register|change-password|reset|.*\\.[svg|json|png|jpg|jpeg|gif|css|js]).*)', + '/', ], }