1
0
Fork 0

Compare commits

..

No commits in common. "6d694ee9eead653c9a4b96b65fdbc72e0ba30932" and "f2c8bc3ae026b96ad3d1b875a4ff55b0c3eb8c27" have entirely different histories.

4 changed files with 6020 additions and 5983 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.10.2",
"react": "^16.9.0",
"react-cookie": "^4.0.1",
"react-dom": "^16.10.2",
"react-dom": "^16.9.0",
"react-markdown": "^4.2.2",
"react-redux": "^7.1.1",
"react-router-dom": "^5.1.2",
"react-router-dom": "^5.0.1",
"react-scripts": "3.0.0",
"redux": "^4.0.4",
"redux-thunk": "^2.3.0",

View file

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

View file

@ -1,3 +1,7 @@
import Cookies from 'universal-cookie';
const cookies = new Cookies();
const initialState = {
user_logged_in: false,
username: '',
@ -8,6 +12,19 @@ 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