Firebase create authentication new account
createUserWithEmailAndPassword(auth,email,password)
.then((userCredential)=>{
//already sign in
const user = userCredential.user;
//...
}).catch((error)=>{
const errorCode = error.code;
const errorMessage = error.message;
//...
})
-----------------------------------------------------------------------------------
-------
Firebase create authentication email account
signInWithEmailAndPassword(auth,email,password)
.then((userCredential)=>{
//already sign in
const user = userCredential.user;
//...
}).catch((error)=>{
const errorCode = error.code;
const errorMessage = error.message;
//...
})
-----------------------------------------------------------------------------------
-------
Firebase create authentication third party account
const provider = new GoogleAuthProvider; //or facebook,twitter...
//open that window
signInWithPopup(auth,provider)
.then((result)=>{
//already sign in
const user = result.user;
//...
}).catch((error)=>{
const errorCode = error.code;
const errorMessage = error.message;
//...
})
-----------------------------------------------------------------------------------
-------
Check user Sign?
//when createUserWithEmailAndPassword or signInWithEmailAndPassword success
onAuthStateChanged(auth,(user)=>{
if(user){
//already sign in
const name = user.displayName;
const email = user.email;
const uid = user.uid;
}else
{
//
}
-----------------------------------------------------------------------------------
-