Skip to content

Commit

Permalink
Merge pull request #16 from farcasterxyz/horsefacts/sign-out
Browse files Browse the repository at this point in the history
feat: sign out button
  • Loading branch information
horsefacts authored Jan 26, 2024
2 parents e0609c5 + ce741fa commit 7030258
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
7 changes: 3 additions & 4 deletions web/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import { getServerSession } from 'next-auth';
import { authOptions } from './api/auth/[...nextauth]/route';

export default async function Home() {
const {
user: { fid },
} = await getServerSession(authOptions);
const session = await getServerSession(authOptions);

if (fid) {
if (session) {
const { user: { fid } } = session;
return (
<div>
<FeedPage fid={fid} />
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ async function getNonce() {
}

async function handleSuccess(res: StatusAPIResponse) {
const signInResponse = await signIn("credentials", {
await signIn("credentials", {
message: res.message,
signature: res.signature,
name: res.username,
pfp: res.pfpUrl,
redirect: false,
redirect: true,
});
}

Expand Down
7 changes: 7 additions & 0 deletions web/src/components/logout/Logout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"use client";

import { signOut } from "next-auth/react";

export default function Logout() {
return <button type="button" className="px-4 py-2 text-white bg-fc-purple rounded cursor-pointer" onClick={() => signOut()}>Sign out</button>;
}
9 changes: 7 additions & 2 deletions web/src/components/profile/Profile.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { User } from '@shared/types/models';

import { Avatar } from '../avatar/Avatar';
import Logout from '../logout/Logout';

type ProfileProps = {
user: User;
Expand All @@ -11,11 +12,15 @@ export function Profile({ user }: ProfileProps) {
<div className="flex flex-col p-4">
<div className="flex flex-row place-items-center">
<Avatar user={user} pfpDiameter={72} />
<div className="flex flex-col ml-4 text-l">
<span className="font-bold">{user.display_name}</span>
<div className="flex flex-col ml-4">
<span className="font-bold">
{user.display_name}
</span>
<span className="text-gray-500">@{user.username}</span>
<div className="mt-2">{user.bio}</div>
</div>
<div className="flex-grow" />
<Logout />
</div>
</div>
);
Expand Down
6 changes: 5 additions & 1 deletion web/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import type { Config } from "tailwindcss";
const config: Config = {
content: ["./src/**/*.{js,ts,jsx,tsx,mdx}"],
theme: {
extend: {},
extend: {
colors: {
'fc-purple': '#7c65c1'
}
},
},
plugins: [],
};
Expand Down

0 comments on commit 7030258

Please sign in to comment.