From d3e4bb3ed2585859a3adeb7eeff35b7c75ebd840 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sun, 16 Sep 2018 22:40:05 +0200 Subject: auth gate on main app. pull in auth routes from bucky. --- app/client/auth/auth.gate.js | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 app/client/auth/auth.gate.js (limited to 'app/client/auth/auth.gate.js') diff --git a/app/client/auth/auth.gate.js b/app/client/auth/auth.gate.js new file mode 100644 index 0000000..e7a9940 --- /dev/null +++ b/app/client/auth/auth.gate.js @@ -0,0 +1,41 @@ +import { h, Component } from 'preact'; +// import PropTypes from 'prop-types'; +import { BrowserRouter, Route } from 'react-router-dom' +import { bindActionCreators } from 'redux'; +import { connect } from 'react-redux'; +import { Redirect } from 'react-router-dom'; + +import Login from './login.component'; +import Logout from './logout.component'; +import Signup from './signup.component'; + +import { randint } from '../util/math' + +class AuthGate extends Component { + render(){ + if (this.props.auth.isAuthenticated) return children + return ( + +
+
+ + + + +
+
+ ) + } + componentDidMount(){ + document.querySelector('.spinfx').style.backgroundImage = 'linear-gradient(' + (randint(40)-5) + 'deg, #fde, #ffe)' + } +} + +const mapStateToProps = (state) => ({ + auth: state.auth +}); + +const mapDispatchToProps = (dispatch) => ({ +}); + +export default connect(mapStateToProps, mapDispatchToProps)(AuthGate); -- cgit v1.2.3-70-g09d2