Compare commits
No commits in common. "6d694ee9eead653c9a4b96b65fdbc72e0ba30932" and "f2c8bc3ae026b96ad3d1b875a4ff55b0c3eb8c27" have entirely different histories.
6d694ee9ee
...
f2c8bc3ae0
4 changed files with 6020 additions and 5983 deletions
11974
package-lock.json
generated
11974
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -5,12 +5,12 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.18.1",
|
"axios": "^0.18.1",
|
||||||
"github-markdown-css": "^3.0.1",
|
"github-markdown-css": "^3.0.1",
|
||||||
"react": "^16.10.2",
|
"react": "^16.9.0",
|
||||||
"react-cookie": "^4.0.1",
|
"react-cookie": "^4.0.1",
|
||||||
"react-dom": "^16.10.2",
|
"react-dom": "^16.9.0",
|
||||||
"react-markdown": "^4.2.2",
|
"react-markdown": "^4.2.2",
|
||||||
"react-redux": "^7.1.1",
|
"react-redux": "^7.1.1",
|
||||||
"react-router-dom": "^5.1.2",
|
"react-router-dom": "^5.0.1",
|
||||||
"react-scripts": "3.0.0",
|
"react-scripts": "3.0.0",
|
||||||
"redux": "^4.0.4",
|
"redux": "^4.0.4",
|
||||||
"redux-thunk": "^2.3.0",
|
"redux-thunk": "^2.3.0",
|
||||||
|
|
|
@ -22,11 +22,9 @@ export const userLogin = (username, password) => async (dispatch) => {
|
||||||
const response = await sudoscientist.post('/auth/signin', {
|
const response = await sudoscientist.post('/auth/signin', {
|
||||||
username: username,
|
username: username,
|
||||||
password: password
|
password: password
|
||||||
},
|
})
|
||||||
{withCredentials: true},
|
|
||||||
)
|
|
||||||
if (response.status === 401) {
|
if (response.status === 401) {
|
||||||
console.log("Please check your credentials")
|
alert("Please check your credentials")
|
||||||
}
|
}
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
dispatch({ type: 'USER_LOGIN', payload: response })
|
dispatch({ type: 'USER_LOGIN', payload: response })
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
import Cookies from 'universal-cookie';
|
||||||
|
|
||||||
|
const cookies = new Cookies();
|
||||||
|
|
||||||
const initialState = {
|
const initialState = {
|
||||||
user_logged_in: false,
|
user_logged_in: false,
|
||||||
username: '',
|
username: '',
|
||||||
|
@ -8,6 +12,19 @@ const initialState = {
|
||||||
export default (state = initialState, action) => {
|
export default (state = initialState, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case 'USER_LOGIN':
|
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, ...{
|
return {...state, ...{
|
||||||
username: action.payload.data.username,
|
username: action.payload.data.username,
|
||||||
user_logged_in: true
|
user_logged_in: true
|
||||||
|
|
Reference in a new issue