Skip to content

Commit f3e8149

Browse files
authored
Merge branch 'canary' into remove-babel-preset-modules
2 parents 272c085 + 5ecdcab commit f3e8149

File tree

4 files changed

+27
-30
lines changed

4 files changed

+27
-30
lines changed

examples/with-firebase-authentication/components/FirebaseAuth.js

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* globals window */
2-
import { useEffect, useState } from 'react'
31
import StyledFirebaseAuth from 'react-firebaseui/StyledFirebaseAuth'
42
import firebase from 'firebase/app'
53
import 'firebase/auth'
@@ -24,29 +22,19 @@ const firebaseAuthConfig = {
2422
credentialHelper: 'none',
2523
callbacks: {
2624
signInSuccessWithAuthResult: async ({ user }, redirectUrl) => {
27-
const userData = mapUserData(user)
25+
const userData = await mapUserData(user)
2826
setUserCookie(userData)
2927
},
3028
},
3129
}
3230

3331
const FirebaseAuth = () => {
34-
// Do not SSR FirebaseUI, because it is not supported.
35-
// https://github.com/firebase/firebaseui-web/issues/213
36-
const [renderAuth, setRenderAuth] = useState(false)
37-
useEffect(() => {
38-
if (typeof window !== 'undefined') {
39-
setRenderAuth(true)
40-
}
41-
}, [])
4232
return (
4333
<div>
44-
{renderAuth ? (
45-
<StyledFirebaseAuth
46-
uiConfig={firebaseAuthConfig}
47-
firebaseAuth={firebase.auth()}
48-
/>
49-
) : null}
34+
<StyledFirebaseAuth
35+
uiConfig={firebaseAuthConfig}
36+
firebaseAuth={firebase.auth()}
37+
/>
5038
</div>
5139
)
5240
}
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
export const mapUserData = (user) => {
2-
const { uid, email, xa, ya } = user
1+
export const mapUserData = async (user) => {
2+
const { uid, email } = user
3+
const token = await user.getIdToken(true)
34
return {
45
id: uid,
56
email,
6-
token: xa || ya,
7+
token,
78
}
89
}

examples/with-firebase-authentication/utils/auth/useUser.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,18 @@ const useUser = () => {
3333
// Firebase updates the id token every hour, this
3434
// makes sure the react state and the cookie are
3535
// both kept up to date
36-
const cancelAuthListener = firebase.auth().onIdTokenChanged((user) => {
37-
if (user) {
38-
const userData = mapUserData(user)
39-
setUserCookie(userData)
40-
setUser(userData)
41-
} else {
42-
removeUserCookie()
43-
setUser()
44-
}
45-
})
36+
const cancelAuthListener = firebase
37+
.auth()
38+
.onIdTokenChanged(async (user) => {
39+
if (user) {
40+
const userData = await mapUserData(user)
41+
setUserCookie(userData)
42+
setUser(userData)
43+
} else {
44+
removeUserCookie()
45+
setUser()
46+
}
47+
})
4648

4749
const userFromCookie = getUserFromCookie()
4850
if (!userFromCookie) {

vercel.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"github": {
3+
"silent": true,
4+
"autoJobCancelation": true
5+
}
6+
}

0 commit comments

Comments
 (0)