1- import { GoogleAuthProvider , signInWithPopup } from 'firebase/auth'
1+ import { GithubAuthProvider , GoogleAuthProvider , signInWithPopup } from 'firebase/auth'
22import { FaGithub , FaGoogle } from 'react-icons/fa'
33import ReactModal from 'react-modal'
44import toast from 'react-simple-toasts'
5- import { auth , provider } from '../api/Config'
5+ import { auth , githubProvider , googleProvider } from '../api/Config'
66
77type AuthModalProps = {
88 showAuth : boolean
@@ -11,7 +11,7 @@ type AuthModalProps = {
1111
1212export const AuthModal = ( { showAuth, setShowAuth } : AuthModalProps ) => {
1313 const signInWithGoogle = ( ) => {
14- signInWithPopup ( auth , provider )
14+ signInWithPopup ( auth , googleProvider )
1515 . then ( ( result ) => {
1616 const credential = GoogleAuthProvider . credentialFromResult ( result )
1717 // TODO save this token in user settings maybe!
@@ -24,6 +24,22 @@ export const AuthModal = ({ showAuth, setShowAuth }: AuthModalProps) => {
2424 toast ( "We couldn't login to you Google account!!" , { theme : 'failure' } )
2525 } )
2626 }
27+
28+ const signInWithGithub = ( ) => {
29+ signInWithPopup ( auth , githubProvider )
30+ . then ( ( result ) => {
31+ const credential = GithubAuthProvider . credentialFromResult ( result )
32+ // TODO save this token in user settings maybe!
33+ const token = credential . accessToken
34+ // The signed-in user info.
35+ const user = result . user
36+ console . log ( user )
37+ } )
38+ . catch ( ( error ) => {
39+ toast ( "We couldn't login to you Github account!!" , { theme : 'failure' } )
40+ } )
41+ }
42+
2743 return (
2844 < ReactModal
2945 isOpen = { showAuth }
@@ -50,12 +66,11 @@ export const AuthModal = ({ showAuth, setShowAuth }: AuthModalProps) => {
5066 </ p >
5167 </ div >
5268 < div >
53- < button type = "button" className = "extraTextWithIconBtn" >
69+ < button className = "extraTextWithIconBtn" onClick = { signInWithGithub } >
5470 < FaGithub />
5571 Sign in with Github
5672 </ button >
5773 < button
58- type = "button"
5974 className = "extraTextWithIconBtn"
6075 style = { { marginLeft : 10 } }
6176 onClick = { signInWithGoogle } >
0 commit comments