From 7e51b29c23e405c4b15add8026086d83d8431d9b Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 3 Nov 2020 16:59:47 -0500 Subject: [PATCH 1/2] Silence GH Comments for Preview URLs (#18766) Disabling GH Comments per @Timer These are the same settings we use for the `vercel/vercel` repo. --- vercel.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 vercel.json diff --git a/vercel.json b/vercel.json new file mode 100644 index 0000000000000..3d53349522ab3 --- /dev/null +++ b/vercel.json @@ -0,0 +1,6 @@ +{ + "github": { + "silent": true, + "autoJobCancelation": true + } +} From 5ecdcab648e0472bc4de63e403badd4cae592bab Mon Sep 17 00:00:00 2001 From: Matsumoto Toshi <32378535+toshi1127@users.noreply.github.com> Date: Wed, 4 Nov 2020 10:40:42 +0900 Subject: [PATCH 2/2] fix: Using getIdToken to get a token (#18599) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../components/FirebaseAuth.js | 22 +++++-------------- .../utils/auth/mapUserData.js | 7 +++--- .../utils/auth/useUser.js | 22 ++++++++++--------- 3 files changed, 21 insertions(+), 30 deletions(-) diff --git a/examples/with-firebase-authentication/components/FirebaseAuth.js b/examples/with-firebase-authentication/components/FirebaseAuth.js index 1ce0d10247446..f9e8f295a000e 100644 --- a/examples/with-firebase-authentication/components/FirebaseAuth.js +++ b/examples/with-firebase-authentication/components/FirebaseAuth.js @@ -1,5 +1,3 @@ -/* globals window */ -import { useEffect, useState } from 'react' import StyledFirebaseAuth from 'react-firebaseui/StyledFirebaseAuth' import firebase from 'firebase/app' import 'firebase/auth' @@ -24,29 +22,19 @@ const firebaseAuthConfig = { credentialHelper: 'none', callbacks: { signInSuccessWithAuthResult: async ({ user }, redirectUrl) => { - const userData = mapUserData(user) + const userData = await mapUserData(user) setUserCookie(userData) }, }, } const FirebaseAuth = () => { - // Do not SSR FirebaseUI, because it is not supported. - // https://github.com/firebase/firebaseui-web/issues/213 - const [renderAuth, setRenderAuth] = useState(false) - useEffect(() => { - if (typeof window !== 'undefined') { - setRenderAuth(true) - } - }, []) return (
- {renderAuth ? ( - - ) : null} +
) } diff --git a/examples/with-firebase-authentication/utils/auth/mapUserData.js b/examples/with-firebase-authentication/utils/auth/mapUserData.js index 5421e3dc5d1d4..ff29018c47609 100644 --- a/examples/with-firebase-authentication/utils/auth/mapUserData.js +++ b/examples/with-firebase-authentication/utils/auth/mapUserData.js @@ -1,8 +1,9 @@ -export const mapUserData = (user) => { - const { uid, email, xa, ya } = user +export const mapUserData = async (user) => { + const { uid, email } = user + const token = await user.getIdToken(true) return { id: uid, email, - token: xa || ya, + token, } } diff --git a/examples/with-firebase-authentication/utils/auth/useUser.js b/examples/with-firebase-authentication/utils/auth/useUser.js index f300fc1bbf241..9a31588217775 100644 --- a/examples/with-firebase-authentication/utils/auth/useUser.js +++ b/examples/with-firebase-authentication/utils/auth/useUser.js @@ -33,16 +33,18 @@ const useUser = () => { // Firebase updates the id token every hour, this // makes sure the react state and the cookie are // both kept up to date - const cancelAuthListener = firebase.auth().onIdTokenChanged((user) => { - if (user) { - const userData = mapUserData(user) - setUserCookie(userData) - setUser(userData) - } else { - removeUserCookie() - setUser() - } - }) + const cancelAuthListener = firebase + .auth() + .onIdTokenChanged(async (user) => { + if (user) { + const userData = await mapUserData(user) + setUserCookie(userData) + setUser(userData) + } else { + removeUserCookie() + setUser() + } + }) const userFromCookie = getUserFromCookie() if (!userFromCookie) {