mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-01 13:42:20 +00:00
0.0.3
- 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:
parent
5fd9d41069
commit
038823055a
23 changed files with 413 additions and 178 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue