1
0
Fork 0

Compare commits

...

3 commits

Author SHA1 Message Date
6d694ee9ee Fix conflicts 2019-10-05 21:25:27 -04:00
40cb160740 Add with creds to post 2019-10-05 21:24:02 -04:00
b92ae0c31c Update repo 2019-10-05 20:45:38 -04:00
4 changed files with 5983 additions and 6020 deletions

11974
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -5,12 +5,12 @@
"dependencies": {
"axios": "^0.18.1",
"github-markdown-css": "^3.0.1",
"react": "^16.9.0",
"react": "^16.10.2",
"react-cookie": "^4.0.1",
"react-dom": "^16.9.0",
"react-dom": "^16.10.2",
"react-markdown": "^4.2.2",
"react-redux": "^7.1.1",
"react-router-dom": "^5.0.1",
"react-router-dom": "^5.1.2",
"react-scripts": "3.0.0",
"redux": "^4.0.4",
"redux-thunk": "^2.3.0",

View file

@ -22,9 +22,11 @@ export const userLogin = (username, password) => async (dispatch) => {
const response = await sudoscientist.post('/auth/signin', {
username: username,
password: password
})
},
{withCredentials: true},
)
if (response.status === 401) {
alert("Please check your credentials")
console.log("Please check your credentials")
}
if (response.status === 200) {
dispatch({ type: 'USER_LOGIN', payload: response })

View file

@ -1,7 +1,3 @@
import Cookies from 'universal-cookie';
const cookies = new Cookies();
const initialState = {
user_logged_in: false,
username: '',
@ -12,19 +8,6 @@ const initialState = {
export default (state = initialState, action) => {
switch (action.type) {
case 'USER_LOGIN':
const full_jwt = action.payload.data.jwt
const jwt_split = full_jwt.split('.')
const jwt_signature = jwt_split.pop()
const jwt_header_payload = jwt_split.join('.')
cookies.set("jwt.signature", jwt_signature,
{
path: '/',
})
cookies.set("jwt.header_payload", jwt_header_payload,
{
path: '/',
})
cookies.getAll()
return {...state, ...{
username: action.payload.data.username,
user_logged_in: true