custom auth
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
persistentMultipleTabManager
|
||||
} from 'firebase/firestore'
|
||||
import type { Firestore } from 'firebase/firestore'
|
||||
import { getAuth, getRedirectResult } from 'firebase/auth'
|
||||
|
||||
// import { getAnalytics } from "firebase/analytics";
|
||||
// TODO: Add SDKs for Firebase products that you want to use
|
||||
@@ -34,8 +35,37 @@ export const signOut = () => firebase.auth().signOut()
|
||||
export const db = ref<Firestore>()
|
||||
|
||||
// Initialize Firebase
|
||||
export const initializeFirebase = () => {
|
||||
export const initializeFirebase = async () => {
|
||||
const app = firebase.initializeApp(firebaseConfig)
|
||||
const auth = getAuth()
|
||||
try {
|
||||
const authRedirectResult = await getRedirectResult(auth)
|
||||
console.log(authRedirectResult)
|
||||
// user.value = result
|
||||
// This gives you a Google Access Token. You can use it to access Google APIs.
|
||||
// const credential = GoogleAuthProvider.credentialFromResult(result)
|
||||
// const token = credential.accessToken
|
||||
|
||||
// The signed-in user info.
|
||||
// const user = result.user
|
||||
// IdP data available using getAdditionalUserInfo(result)
|
||||
// ...
|
||||
} catch (error: any) {
|
||||
console.error(error)
|
||||
// const errorCode = error.code
|
||||
// // const errorMessage = error.message
|
||||
// const email = error.customData.email
|
||||
|
||||
// Handle Errors here.
|
||||
// const errorCode = error.code
|
||||
// const errorMessage = error.message
|
||||
// The email of the user's account used.
|
||||
// const email = error.customData.email
|
||||
// The AuthCredential type that was used.
|
||||
// const credential = GoogleAuthProvider.credentialFromError(error)
|
||||
// ...
|
||||
}
|
||||
|
||||
firebase.auth().onAuthStateChanged((firebaseUser) => {
|
||||
user.value = firebaseUser
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user