Skip to content

Commit

Permalink
github signin popup button functioning
Browse files Browse the repository at this point in the history
  • Loading branch information
carmenkolohe committed Jul 4, 2021
1 parent 6bcbfc1 commit 4b1e4f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
10 changes: 8 additions & 2 deletions components/signin/GitHubSignInButton.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import firebase from 'firebase/app'

import 'firebaseui/dist/firebaseui.css'
import { useEffect } from 'react'

const GitHubSignInButton = () => {
useEffect(async () => {
const firebaseui = await import('firebaseui')
const uiConfig = {
signInOptions: [firebase.auth.GithubAuthProvider.PROVIDER_ID],
signInFlow: 'popup',
signInOptions: [
{
provider: firebase.auth.GithubAuthProvider.PROVIDER_ID,
signInMethod: firebase.auth.GithubAuthProvider.PROVIDER_ID,
},
],
}
if (firebaseui.auth.AuthUI.getInstance()) {
const ui = firebaseui.auth.AuthUI.getInstance()
Expand All @@ -17,6 +22,7 @@ const GitHubSignInButton = () => {
ui.start('#firebaseui-auth-container', uiConfig)
}
})

return <div id='firebaseui-auth-container' />
}

Expand Down
11 changes: 1 addition & 10 deletions pages/sign-in.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import GitHubSignInButton from 'components/signin/GitHubSignInButton'

const SignIn = () => {
const router = useRouter()
const { currentUser, signin, signInWithGithub } = useAuth()
const { currentUser, signin } = useAuth()
const [loading, setLoading] = useState(true)
const [error, setError] = useState(null)

Expand Down Expand Up @@ -49,15 +49,6 @@ const SignIn = () => {
setLoading(false)
}

const handleSignInWithGithub = async (data) => {
try {
await signInWithGithub()
router.push('/dashboard')
} catch (error) {
setError(error.messge)
}
}

return (
<div className='max-w-screen-xl py-12 mx-auto md:flex'>
<div className='mb-12 md:w-1/3 md:mr-24 md:mb-0 md:mt-6'>
Expand Down

0 comments on commit 4b1e4f4

Please sign in to comment.