Skip to content

Commit

Permalink
chore: update guestbook
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjin871114 committed Aug 2, 2024
1 parent bf5e2c0 commit 2ab962c
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions src/app/[locale]/guestbook/page.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
import { signIn, signOut , auth } from '@/lib/auth';
import Image from 'next/image';

const GuestbookPage = async () => {
const session = await auth();

if (!session?.user) {
return (
<>
<form
action={async () => {
'use server';
await signIn('github');
}}
>
<button type='submit'>Signin with GitHub</button>
</form>
</>
);
}

return (
<>
<h1>Welcome {session.user.name}</h1>
<Image width={60} height={60} alt='avatar' src={session.user.image as string} />
<form
action={async () => {
'use server';
await signIn('github');
await signOut();
}}
>
<button type='submit'>Signin with GitHub</button>
<button type='submit'>Signout with GitHub</button>
</form>
);
}

return (
<form
action={async () => {
'use server';
await signOut();
}}
>
<button type='submit'>Signout with GitHub</button>
</form>
<input type="text" placeholder='leave you message' />
</>
);
};

Expand Down

0 comments on commit 2ab962c

Please sign in to comment.