Skip to content

Commit

Permalink
Merge pull request #7 from sryung1225/dev
Browse files Browse the repository at this point in the history
회원가입 과정 보완 (#3)
  • Loading branch information
sryung1225 authored Dec 15, 2023
2 parents 75ed77b + 095fec7 commit ec7639d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/components/socialSignIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import React, { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { FirebaseError } from 'firebase/app';
import { AuthProvider, signInWithPopup } from 'firebase/auth';
import { auth } from '../firebase.ts';
import { doc, setDoc } from 'firebase/firestore';
import { auth, db } from '../firebase.ts';
import * as S from '../styles/auth.ts';

interface ISocialButton {
Expand All @@ -22,7 +23,13 @@ export default function SocialSignIn({ provider, icon, text }: ISocialButton) {
const onClick = async () => {
setFirebaseError('');
try {
await signInWithPopup(auth, provider);
const credentials = await signInWithPopup(auth, provider);
const userRef = doc(db, 'users', credentials.user.uid);
await setDoc(userRef, {
userName: credentials.user.displayName || 'Anonymous',
userId: credentials.user.uid,
userAvatar: credentials.user.photoURL || null,
});
navigate('/');
} catch (error) {
if (error instanceof FirebaseError) {
Expand Down

0 comments on commit ec7639d

Please sign in to comment.