Skip to content

Commit

Permalink
set redirect from index page
Browse files Browse the repository at this point in the history
  • Loading branch information
purinx committed Dec 12, 2023
1 parent ff29483 commit c60e0d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 59 deletions.
1 change: 1 addition & 0 deletions src/app/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const DashboardPage = async () => {

const { data: auth } = await supabase.auth.getUser(token.value);
if (!auth.user) {
cookie.delete('token');
redirect('/auth/sign-in');
}
const { data: user } = await supabase
Expand Down
67 changes: 8 additions & 59 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,64 +1,13 @@
import Image from 'next/image';

import styles from './page.module.css';
import { cookies } from 'next/headers';
import { redirect } from 'next/navigation';

export default function Home() {
return (
<main className="container">
<div className={styles.center}>
<Image
className={styles.logo}
src="/next.svg"
alt="Next.js Logo"
width={180}
height={37}
priority
/>
</div>
<div className={styles.grid}>
<a
href="/auth/register"
className={styles.card}
target="_blank"
rel="noopener noreferrer"
>
<h2>
Register<span>-&gt;</span>
</h2>
</a>
<a
href="/auth/sign-in"
className={styles.card}
target="_blank"
rel="noopener noreferrer"
>
<h2>
Sign In <span>-&gt;</span>
</h2>
</a>
const cookie = cookies();
const token = cookie.get('token');

<a
href="/dashboard"
className={styles.card}
target="_blank"
rel="noopener noreferrer"
>
<h2>
Dashboard <span>-&gt;</span>
</h2>
</a>
if (token) {
redirect('/dashboard');
}

<a
href="https://github.com/caburchin/neko-auth"
className={styles.card}
target="_blank"
rel="noopener noreferrer"
>
<h2>
Github<span>-&gt;</span>
</h2>
</a>
</div>
</main>
);
redirect('/auth/sign-in');
}

0 comments on commit c60e0d2

Please sign in to comment.