Skip to content

Latest commit

 

History

History
162 lines (120 loc) · 4.47 KB

MIGRATION.md

File metadata and controls

162 lines (120 loc) · 4.47 KB

2.x to 3.x Migration Guide

Here are some examples of how to replace the deprecated authentication methods.

The examples are assuming the use of the default firebase app instance (named '[DEFAULT]'). You can pass auth() an initialized firebase app in order to have the auth service associated with a different app instance.

Ex.

var firebase = require('firebase/app');
require('firebase/auth');
var myApp = firebase.initializeApp(yourConfig, 'myApp');
var myAppAuth = firebase.auth(myApp);

base.authWithPassword

var firebase = require('firebase/app');
require('firebase/auth');
var app = firebase.initializeApp(yourConfig);

app.auth().signInWithEmailAndPassword(email, password).then(user => {
  //
});

See Firebase docs for more information.

base.onAuth

var firebase = require('firebase/app');
require('firebase/auth');
var app = firebase.initializeApp(yourConfig);

app.auth().onAuthStateChanged(function(user, error) {
  //
});

See Firebase docs for more information.

base.unAuth

var firebase = require('firebase/app');
require('firebase/auth');
var app = firebase.initializeApp(yourConfig);

app.auth().signOut().then(() => {
  //return value is null
});

See Firebase docs for more information.

base.getAuth

var firebase = require('firebase/app');
require('firebase/auth');
var app = firebase.initializeApp(yourConfig);

app.auth().currentUser;

See Firebase docs for more information.

base.createUser

var firebase = require('firebase/app');
require('firebase/auth');
var app = firebase.initializeApp(yourConfig);

app.auth().createUserWithEmailAndPassword(email,password).then(user => {
  //
});

See Firebase Docs for more information.

base.resetPassword

var firebase = require('firebase/app');
require('firebase/auth');
var app = firebase.initializeApp(yourConfig);

app.auth().sendPasswordResetEmail(email).then(...)

See Firebase Docs for more information.

base.authWithCustomToken

var firebase = require('firebase/app');
require('firebase/auth');
var app = firebase.initializeApp(yourConfig);

app.auth().signInWithCustomToken(token).then(user => {
  //
})

See Firebase Docs for more information.

base.authWithOAuthPopup

var firebase = require('firebase/app');
require('firebase/auth');
var app = firebase.initializeApp(yourConfig);

var provider = new firebase.auth.FacebookAuthProvider();
app.auth().signInWithPopup(provider).then(() => {
  //return value is null
});

See Firebase Docs for more information.

base.getOAuthRedirectResult

var firebase = require('firebase/app');
require('firebase/auth');
var app = firebase.initializeApp(yourConfig);

app.auth().getRedirectResult().then(function(result) {
  //
});

See Firebase Docs for more information.

base.authWithOAuthToken

var firebase = require('firebase/app');
require('firebase/auth');
var app = firebase.initializeApp(yourConfig);

var provider = new firebase.auth.FacebookAuthProvider();
var credential = provider.credential(OAuthToken, settings);

auth.signInWithCredential(credential).then(user => {
  //
});

See Firebase Docs

base.authWithOAuthRedirect

var firebase = require('firebase/app');
require('firebase/auth');
var app = firebase.initializeApp(yourConfig);

var provider = new firebase.auth.FacebookAuthProvider();
app.auth().signInWithRedirect(provider).then(() => {
  //return value is null
});

See Firebase Docs for more information.