Browse Source

Fix auth bugs

apollo
sipp11 6 years ago
parent
commit
8d91012015
  1. 8
      src/container/Gone.js
  2. 2
      src/reducers/auth.js

8
src/container/Gone.js

@ -19,15 +19,15 @@ const Gone = (props) => (
{props.loggedIn ? 'Logged in': 'Nah anonymous'} {props.loggedIn ? 'Logged in': 'Nah anonymous'}
<hr /> <hr />
<button onClick={_ => props.fetchAuth("user", "passwd")}>Login</button> <button onClick={_ => fetchAuth("user", "passwd")}>Login</button>
</div> </div>
) )
const mapStateToProps = state => ({ const mapStateToProps = state => ({
token: getToken(state.auth) token: getToken(state.auth),
loggedIn: loggedIn(state.auth),
}) })
export default connect( export default connect(
mapStateToProps, mapStateToProps
{ loggedIn, fetchAuth }
)(Gone) )(Gone)

2
src/reducers/auth.js

@ -37,4 +37,4 @@ const token = (state = tokenInitialState, action) => {
export default token export default token
export const getToken = state => state.token export const getToken = state => state.token
export const loggedIn = state => state && state.token == null export const loggedIn = state => state && state.token !== null

Loading…
Cancel
Save