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
- Host: GitHub
- URL: https://github.com/mutualmobile/reactfirebaseauthcomponent
- Owner: mutualmobile
- License: mit
- Created: 2017-05-26T20:01:02.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-08T17:06:14.000Z (about 9 years ago)
- Last Synced: 2025-01-13T06:26:33.027Z (over 1 year ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 1
- Watchers: 13
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
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;
```