- Clean up login/redirect flow
- Add redirect when not authed on other endpoints
- Add GET /stats endpoint for overal stats
This commit is contained in:
Daniel Mason 2021-03-30 15:02:04 +13:00
parent 5fd9d41069
commit 038823055a
Signed by: idanoo
GPG key ID: 387387CDBC02F132
23 changed files with 413 additions and 178 deletions

View file

@ -6,11 +6,11 @@ import {
LOGOUT,
} from "../Actions/types";
const jwt = localStorage.getItem("jwt");
const user = JSON.parse(localStorage.getItem('user'));
const initialState = jwt
? { isLoggedIn: true, jwt }
: { isLoggedIn: false, jwt };
const initialState = user
? { isLoggedIn: true, user: user }
: { isLoggedIn: false, user: null };
export default function authReducer(state = initialState, action) {
const { type, payload } = action;
@ -30,13 +30,16 @@ import {
return {
...state,
isLoggedIn: true,
user: payload.user,
user: {
jwt: payload.jwt,
uuid: payload.sub,
exp: payload.exp,
}
};
case LOGIN_FAIL:
return {
...state,
isLoggedIn: false,
user: null,
};
case LOGOUT:
return {