Advertisement
Guest User

Untitled

a guest
Apr 14th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. export const authSignup = (username, email, password, confirm_password) => {
  2. return dispatch => {
  3. dispatch(authStart());
  4. axios.post('http://127.0.0.1:8000/rest-auth/registration/', {
  5. username: username,
  6. email: email,
  7. password: password,
  8. confirm_password: confirm_password
  9. })
  10. .then(res => {
  11. const token = res.data.key;
  12. const expirationDate = new Date(new Date().getTime() + 3600 * 1000);
  13. localStorage.setItem('token', token);
  14. localStorage.setItem('expirationDate', expirationDate);
  15. dispatch(authSuccess(token));
  16. dispatch(checkAuthTimeout(3600));
  17. })
  18. .catch(err => {
  19. dispatch(authFail(err))
  20. })
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement