mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2026-03-10 21:25:04 +00:00
Merge branch 'master' into edit-profile-image-upload
This commit is contained in:
@@ -1,6 +1,20 @@
|
||||
import {SET_USER, SET_ERRORS, CLEAR_ERRORS, LOADING_UI, SET_AUTHENTICATED, SET_UNAUTHENTICATED, LOADING_USER} from '../types';
|
||||
import {
|
||||
SET_USER,
|
||||
SET_ERRORS,
|
||||
CLEAR_ERRORS,
|
||||
LOADING_UI,
|
||||
// SET_AUTHENTICATED,
|
||||
SET_UNAUTHENTICATED,
|
||||
LOADING_USER
|
||||
} from '../types';
|
||||
import axios from 'axios';
|
||||
|
||||
const setAuthorizationHeader = (token) => {
|
||||
const FBIdToken = `Bearer ${token}`;
|
||||
localStorage.setItem('FBIdToken', FBIdToken);
|
||||
axios.defaults.headers.common['Authorization'] = FBIdToken;
|
||||
}
|
||||
|
||||
// Gets Database info for the logged in user and sets it in Redux
|
||||
export const getUserData = () => (dispatch) => {
|
||||
dispatch({ type: LOADING_USER });
|
||||
@@ -24,7 +38,7 @@ export const loginUser = (loginData, history) => (dispatch) => {
|
||||
// Save the login token
|
||||
setAuthorizationHeader(res.data.token);
|
||||
dispatch(getUserData());
|
||||
dispatch({ type: CLEAR_ERRORS })
|
||||
// dispatch({ type: CLEAR_ERRORS })
|
||||
// Redirects to home page
|
||||
history.push('/home');
|
||||
})
|
||||
@@ -47,7 +61,7 @@ export const signupUser = (newUserData, history) => (dispatch) => {
|
||||
// Save the signup token
|
||||
setAuthorizationHeader(res.data.token);
|
||||
dispatch(getUserData());
|
||||
dispatch({ type: CLEAR_ERRORS })
|
||||
// dispatch({ type: CLEAR_ERRORS })
|
||||
// Redirects to home page
|
||||
history.push('/home');
|
||||
})
|
||||
@@ -105,4 +119,4 @@ export const uploadImage = (formData) => (dispatch) => {
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user