gifFirebaseRef.on('value', snapshot => { const gifURL = snapshot.val() || ''; // got the url, stop listening for changes if (gifURL) { gifFirebaseRef.off(); this.goOffline(); setMessage(''); this.setState( { gifFirebaseRef, gifURL, loading: false, processing: false }, () => { this.updateBackgroundColor(); this.updateAddThis(); }, ); } else if (!processing) { this.goOffline(); setMessage(''); // user opened by url // we saw if exists. it didnt. so lets redirect it to the main page push(`/#${subject}`); } });
/** * Handles a signed in user. Sets the session cookie and then redirects to * profile page on success. * @param {!firebase.User} user */ const handleSignedInUser = function(user) { // Show redirection notice. document.getElementById('redirecting').classList.remove('hidden'); // Set session cookie user.getIdToken().then(function(idToken) { // Session login endpoint is queried and the session cookie is set. // CSRF token should be sent along with request. const csrfToken = getCookie('csrfToken') return postIdTokenToSessionLogin('/sessionLogin', idToken, csrfToken) .then(function() { // Redirect to profile on success. window.location.assign('/profile'); }, function(error) { // Refresh page on error. // In all cases, client side state should be lost due to in-memory // persistence. window.location.assign('/'); }); }); }
'signInOptions': [ provider: firebase.auth.GoogleAuthProvider.PROVIDER_ID }, provider: firebase.auth.EmailAuthProvider.PROVIDER_ID,
constructor(props) { super(props); this.state = { dataSource: new ListView.DataSource({ rowHasChanged: (row1, row2) => row1 !== row2, }), loading: true }; this.friendsRef = this.getRef().child('friends'); navigator = this.props.navigator }
/** * Initialises Firebase */ static initialise() { firebase.initializeApp({ apiKey: "yourkeyhere", authDomain: "projName-d0c3e.firebaseapp.com", databaseURL: "https://projName-d0c3e.firebaseio.com", storageBucket: "projName-d0c3e.appspot.com" }); }
getInitialView() { firebase.auth().onAuthStateChanged((user) => { let initialView = user ? "Home" : "Login"; this.setState({ userLoaded: true, initialView: initialView }) }); }
authRef .currentUser .updateEmail(newEmail) .then(() => { this.setState({ success: true, working: false }); }, error => { this.setState({ error: error.message, working: false }); });
const addToFavoriteQuotes = (quote) => { quote.timestamp = getTimeStamp(); return new Promise((resolve, reject) => { firebase .addToFavoriteQuotes(quote) .then(() => resolve(quote)) .catch(error => reject(error)); }); }
componentDidMount() { // Verify the password reset code is valid. authRef .verifyPasswordResetCode(this.props.actionCode) .then(email => { this.setState({ email, validCode: true, verifiedCode: true }); }, error => { // Invalid or expired action code. Ask user to try to reset the password // again. this.setState({ error: error.message, validCode: false, verifiedCode: true }); }); }
gifFirebaseRef.on('value', snapshot => { const gifURL = snapshot.val() || ''; // got the url, stop listening for changes if (gifURL) { gifFirebaseRef.off(); this.goOffline(); setMessage(''); this.setState( { gifFirebaseRef, gifURL, loading: false, processing: false }, () => { this.updateBackgroundColor(); this.updateAddThis(); }, ); } else if (!processing) { this.goOffline(); setMessage(''); // user opened by url // we saw if exists. it didnt. so lets redirect it to the main page push(`/#${subject}`); } });
/** * Handles a signed in user. Sets the session cookie and then redirects to * profile page on success. * @param {!firebase.User} user */ const handleSignedInUser = function(user) { // Show redirection notice. document.getElementById('redirecting').classList.remove('hidden'); // Set session cookie user.getIdToken().then(function(idToken) { // Session login endpoint is queried and the session cookie is set. // CSRF token should be sent along with request. const csrfToken = getCookie('csrfToken') return postIdTokenToSessionLogin('/sessionLogin', idToken, csrfToken) .then(function() { // Redirect to profile on success. window.location.assign('/profile'); }, function(error) { // Refresh page on error. // In all cases, client side state should be lost due to in-memory // persistence. window.location.assign('/'); }); }); }
'signInOptions': [ provider: firebase.auth.GoogleAuthProvider.PROVIDER_ID }, provider: firebase.auth.EmailAuthProvider.PROVIDER_ID,