Browse Source

Fix auth bugs

master
sipp11 6 years ago
parent
commit
85c87fbcfc
  1. 8
      src/container/Gone.js
  2. 2
      src/reducers/auth.js

8
src/container/Gone.js

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

2
src/reducers/auth.js

@ -37,4 +37,4 @@ const token = (state = tokenInitialState, action) => {
export default 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