Last active
October 6, 2017 23:58
-
-
Save DavidLazic/132f4be66325c518c82820730f48cd13 to your computer and use it in GitHub Desktop.
React + Firebase - Persistent auth
This file contains hidden or 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 React, { Component } from 'react'; | |
| import { Router, Route, IndexRoute, browserHistory } from 'react-router'; | |
| import App from 'containers/core/App'; | |
| import Login from 'containers/views/Login'; | |
| import Admin from 'containers/views/Admin'; | |
| import Home from 'containers/views/Home'; | |
| const publicPath = '/'; | |
| export const routeCodes = { | |
| ROOT: publicPath, | |
| LOGIN: `${ publicPath }login`, | |
| ADMIN: `${ publicPath }admin` | |
| }; | |
| const routes = ( | |
| <Route path={ publicPath } component={ App } > | |
| <IndexRoute component={ Home } /> | |
| <Route path={ routeCodes.LOGIN } component={ Login } /> | |
| <Route path={ routeCodes.ADMIN } component={ Admin } protected /> | |
| <Route | |
| path="*" | |
| onEnter={ (next, replace) => replace({ pathname: routeCodes.ROOT }) } | |
| component={ Home } /> | |
| </Route> | |
| ); | |
| export default class Routes extends Component { | |
| render () { | |
| return ( | |
| <Router history={ browserHistory } routes={ routes } /> | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment