Skip to content

Commit

Permalink
feat(api): Handle Farcaster auth from privy login (#236)
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdi-loup authored Jan 27, 2025
1 parent fa71f3c commit ce0ee05
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/helpers/useSignIn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { gql, useMutation } from '@apollo/client';
import { useLogin, useLogout, usePrivy } from '@privy-io/react-auth';

const UPSERT_USER = gql`
mutation UpsertApiClient($email: String!) {
upsertApiClient(email: $email) {
mutation UpsertApiClient($username: String!, $farcasterId: Int) {
upsertApiClient(username: $username, farcasterId: $farcasterId) {
name
}
}
Expand All @@ -24,7 +24,14 @@ export function useSignIn({ onComplete } = { onComplete: () => {} }) {
if (user.email) {
await upsertUser({
variables: {
email: user.email.address,
username: user.email.address,
},
});
} else if (user.farcaster) {
await upsertUser({
variables: {
farcasterId: user.farcaster.fid,
username: user.farcaster.displayName,
},
});
}
Expand Down

0 comments on commit ce0ee05

Please sign in to comment.