Created
July 12, 2016 23:59
-
-
Save steven-ferguson/8eddf63123fa74066e9d92f7e829d8e9 to your computer and use it in GitHub Desktop.
Emberfire + FirebaseUI Authentication
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* globals firebaseui */ | |
import Ember from 'ember'; | |
import firebase from 'firebase'; | |
const { computed, inject: { service } } = Ember; | |
export default Ember.Component.extend({ | |
firebaseApp: service(), | |
didInsertElement() { | |
this._super(...arguments); | |
this._initializeAuthUI(); | |
}, | |
signInSuccess() {}, | |
uiConfig: computed('signInSuccess', function () { | |
return { | |
signInOptions: [ | |
firebase.auth.EmailAuthProvider.PROVIDER_ID, | |
], | |
callbacks: { | |
signInSuccess: this.get('signInSuccess'), | |
}, | |
}; | |
}), | |
elementId: 'firebaseui-auth-container', | |
_initializeAuthUI() { | |
const auth = this.get('firebaseApp').auth(); | |
const ui = new firebaseui.auth.AuthUI(auth); | |
ui.start('#firebaseui-auth-container', this.get('uiConfig')); | |
this.set('ui', ui); | |
}, | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Add these to the bottom of your head tag --> | |
<script src="https://www.gstatic.com/firebasejs/ui/live/0.4/firebase-ui-auth.js"></script> | |
<link type="text/css" rel="stylesheet" href="https://www.gstatic.com/firebasejs/ui/live/0.4/firebase-ui-auth.css" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
const { inject: { service } } = Ember; | |
export default Ember.Controller.extend({ | |
session: service(), | |
actions: { | |
signInSuccess() { | |
this.get('session').fetch().then(() => this.replaceRoute('index')); | |
}, | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Unfortunately I have not used Ember in 3 years, so I am not familiar with any api changes that have occurred since then.