mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-01 13:42:20 +00:00
- Login flow working..
- Jellyfin scrobble working - Returns scrobbles via API for authed users /api/v1/user/{uuid}/scrobble - Add redis handler + funcs - Move middleware to pass in uuid as needed
This commit is contained in:
parent
c83c086cdd
commit
5fd9d41069
54 changed files with 1093 additions and 386 deletions
50
web/src/Reducers/auth.js
Normal file
50
web/src/Reducers/auth.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
import {
|
||||
REGISTER_SUCCESS,
|
||||
REGISTER_FAIL,
|
||||
LOGIN_SUCCESS,
|
||||
LOGIN_FAIL,
|
||||
LOGOUT,
|
||||
} from "../Actions/types";
|
||||
|
||||
const jwt = localStorage.getItem("jwt");
|
||||
|
||||
const initialState = jwt
|
||||
? { isLoggedIn: true, jwt }
|
||||
: { isLoggedIn: false, jwt };
|
||||
|
||||
export default function authReducer(state = initialState, action) {
|
||||
const { type, payload } = action;
|
||||
|
||||
switch (type) {
|
||||
case REGISTER_SUCCESS:
|
||||
return {
|
||||
...state,
|
||||
isLoggedIn: false,
|
||||
};
|
||||
case REGISTER_FAIL:
|
||||
return {
|
||||
...state,
|
||||
isLoggedIn: false,
|
||||
};
|
||||
case LOGIN_SUCCESS:
|
||||
return {
|
||||
...state,
|
||||
isLoggedIn: true,
|
||||
user: payload.user,
|
||||
};
|
||||
case LOGIN_FAIL:
|
||||
return {
|
||||
...state,
|
||||
isLoggedIn: false,
|
||||
user: null,
|
||||
};
|
||||
case LOGOUT:
|
||||
return {
|
||||
...state,
|
||||
isLoggedIn: false,
|
||||
user: null,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue