Skip to content

Commit

Permalink
Merge pull request #14 from paulkevany/auth-loading
Browse files Browse the repository at this point in the history
Fix auth loading spinner bug
  • Loading branch information
Paul Kevany authored Feb 27, 2020
2 parents dfcae06 + 5e0cd31 commit 5c22e9b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
3 changes: 1 addition & 2 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ jspm_packages
.serverless

#amplify
/amplify
amplify/\#current-cloud-backend
amplify/.config/local-*
amplify/mock-data
Expand All @@ -19,4 +18,4 @@ aws-exports.js
awsconfiguration.json
amplifyconfiguration.json
amplify-gradle-config.json
amplifyxc.config
amplifyxc.config
3 changes: 2 additions & 1 deletion frontend/src/Components/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Login extends Component {
handleChange = ({ target: { id, value } }) => this.setState({ [id]: value })

validateInput = () =>
this.state.email.length > 0 && this.state.password.length > 0
this.state.email.length > 3 && this.state.password.length >= 8

handleSubmit = event => {
event.preventDefault()
Expand Down Expand Up @@ -106,6 +106,7 @@ class Login extends Component {
variant="contained"
className={classes.button}
color="primary"
disabled={loggingIn || !this.validateInput()}
>
Login
</Button>
Expand Down
15 changes: 14 additions & 1 deletion frontend/src/Reducers/auth.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { LOGIN_REQUEST, LOGIN_SUCCESS, LOGIN_FAILED } from '../Actions/auth'
import {
LOGIN_REQUEST,
LOGIN_SUCCESS,
LOGIN_FAILED,
AUTHENTICATION_VALIDATED,
AUTHENTICATION_INVALIDATED
} from '../Actions/auth'

const defaultState = {
loggingIn: false,
Expand All @@ -16,13 +22,20 @@ export default (state = defaultState, { type, meta, payload, error }) => {
}

case LOGIN_SUCCESS:
case AUTHENTICATION_VALIDATED:
return {
...state,
loggingIn: false,
authenticated: true,
loginError: null
}

case AUTHENTICATION_INVALIDATED:
return {
...state,
authenticated: false
}

case LOGIN_FAILED:
return {
...state,
Expand Down

0 comments on commit 5c22e9b

Please sign in to comment.