Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
thebkht committed Oct 25, 2023
1 parent cf3ecd7 commit 698508b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 33 deletions.
30 changes: 0 additions & 30 deletions app/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,36 +78,6 @@ export const config = {
}
return true; // Continue sign-in process
},
async jwt({ token, user, session, profile}) {
// Add access_token to the token right after signin
if (user) {
const account = await postgres.user.findFirst({
where: {
image: token.picture,
}
})
return { ...token, id: account?.id, picture: account?.image, username: account?.username, name: account?.name, email: account?.email, bio: account?.bio, githubprofile: account?.githubprofile, location: account?.location, password: account?.password }
}
return token;
},
async session({ session, user, token }) {
// Add property to session, like an access_token from a provider.
return {
...session,
user: {
...session.user,
id: token.id,
picture: token.image,
username: token.username,
name: token.name,
email: token.email,
bio: token.bio,
githubprofile: token.githubprofile,
location: token.location,
password: token.password,
}
}
}
},

} satisfies NextAuthConfig
Expand Down
6 changes: 3 additions & 3 deletions components/user/details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ export default function UserDetails({ className, children, user, followers, foll
useEffect(() => {
async function fetchData(followersRef: React.MutableRefObject<any>, user: any, status: string) {
if (status === "authenticated") {
const followerId = (await getSessionUser()).userid;
const followerId = (await getSessionUser()).id;
const userFollowers = await fetch(`/api/users/${user?.username}`);
const followers = await userFollowers.json().then((res) => res.user.followers);
followersRef.current = followers;
setIsFollowing(followers.find((follower: any) => follower.userid === followerId));
setIsFollowing(followers.find((follower: any) => follower.followerId === followerId));
}
}

Expand All @@ -63,7 +63,7 @@ export default function UserDetails({ className, children, user, followers, foll
setIsFollowingLoading(true);
try {
setIsFollowing(!isFollowing);
const followerId = (await getSessionUser()).userid;
const followerId = (await getSessionUser()).id;
const result = await fetch(`/api/follow?followeeId=${followeeId}&followerId=${followerId}`, {
method: "GET",
});
Expand Down

0 comments on commit 698508b

Please sign in to comment.