An open API service indexing awesome lists of open source software.

https://github.com/mutualmobile/reactfirebaseauthcomponent

Reusable code for simple authentication and integration with Firebase
https://github.com/mutualmobile/reactfirebaseauthcomponent

Last synced: over 1 year ago
JSON representation

Reusable code for simple authentication and integration with Firebase

Awesome Lists containing this project

README

          

# React-Firebase-Mobx-Auth

### This mobx store handles authentication with firebase

### Setup

In your main app entry point (app.js) use the mobx-react Provider to pass this auth store down the component tree

``` javascript
import React, { Component } from 'react';
import {Scene, Router} from 'react-native-router-flux';
import {AppRegistry} from 'react-native';
import {Provider} from 'mobx-react';
import Routes from './Routes';
import Auth from './stores/Auth';

class App extends React.Component {
render() {
return


}
}
AppRegistry.registerComponent('App', () => App);
module.exports = App;
```

In your router you will want to define your firebase library, a success, and failure function.

``` javascript
import React, { Component } from 'react';
import {Scene, Router, Actions} from 'react-native-router-flux';
import { AppRegistry } from 'react-native';
import Login from './components/views/Login';
import Register from './components/views/Register';
import Home from './components/views/Home';
import {observer} from "mobx-react";
import RNFirebase from './modules/RNFirebase';

@observer(['authorization'])
class Routes extends React.Component {
componentDidMount() {
this.props.authorization.bindAuthHandler(
RNFirebase,
user =>{
// successful authentication

this.props.authorization.saveUser(user);
this.props.authorization.setFcmToken(user);
Actions.home()
},
()=>{
// failed authentication
Actions.login()
}
);
}
render() {
return






}
}
AppRegistry.registerComponent('Routes', () => Routes);
module.exports = Routes;
```