-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add tests - add login action creators - add welcome page component [Starts #161290964]
- Loading branch information
1 parent
fac4eaa
commit 133bc3a
Showing
17 changed files
with
306 additions
and
155 deletions.
There are no files selected for viewing
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
.welcome { | ||
margin-top: 5em; | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { toastr } from 'react-redux-toastr'; | ||
|
||
import { globalLoading, globalFailure, globalLoggedIn } from './globalActions'; | ||
import requestOptions from '../utils/requestOptions'; | ||
|
||
export const sendEmailLink = email => dispatch => fetch(`${process.env.API_BASE_URL}/users/login`, requestOptions({ email }, 'POST', null)) | ||
.then( | ||
res => res.json(), | ||
error => dispatch(globalFailure(['An error has occured', error])) | ||
) | ||
.then((jsonResponse) => { | ||
if (jsonResponse.errors) { | ||
dispatch(globalFailure(jsonResponse.errors)); | ||
toastr.error('There was an error please try again'); | ||
} else { | ||
toastr.success('Email sent successfully! Check your email.'); | ||
} | ||
}); | ||
|
||
export const logUserIn = tokenQueryString => dispatch => fetch(`${process.env.API_BASE_URL}/users/login${tokenQueryString}`) | ||
.then(res => res.json(), error => dispatch(globalFailure(['We were unable to log you in, please try again.', error]))) | ||
.then((jsonResponse) => { | ||
if (jsonResponse.errors) { | ||
dispatch(globalFailure(jsonResponse.errors)); | ||
toastr.error('An error has occured, please try again!'); | ||
} else { | ||
dispatch(globalLoading(true)); | ||
localStorage.setItem('token', JSON.stringify(jsonResponse.user.token)); | ||
dispatch(globalLoggedIn(true)); | ||
toastr.success('Login was was successful'); | ||
dispatch(globalLoading(false)); | ||
} | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.