Closed frankcollins3 closed 1 year ago
// disclosure: was imagining a way of doing this manually and chatGPT spit out a version of it going. the point is: --> set add a token object in addition to action.payload -->login, page nav, & useEffect in app.tsx -->check token from app->cookies, if token, fetch user, add state with token.
kind of confused how to set the token.
Almost want to concatenate a string:
${token}id:${id}
---> perform regex upon the concatenated string.
[11:36pm]
psql data: 4 | Google Account in Use. Profile can Fix. | /water_img/bikini.png | tonyhawk | tonyhawk@gmail.com | $2a$13$j1Vx4R5kfw2hNDzFtTTH7uq6Zk6Mu/XuTSlzSoQYhZFXDm0PTh782 | 54
serverside concatenation:
const tokenWithId = ${token}id:${user.id}
client->browsertools->application->cookies->localhost:3000: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NCwiaWF0IjoxNjg5NjUxNDg5fQ.I4023Ewwq1Urxxxr2UXtbJ15aLrPrcZznKRrbZ2JWNgid:4
// already started brainstorming how to manually do this before chatGPT spit out a non-redux-persist way of persisting both pieces of info seem important.
[11:41pm]
// first idea: add id onto end & slice.length-1 to grab last character but that won't work when hitting doubledigit id
for all I know this is super commonplace but feels creative
attempting to do: data persistence.
error: (not so much error but anticipated roadbump / hiccup in creating the plan) Upon login, page is of course navigating away from current route, which returns all state to original values
proposed approach: 0: the original 🚫redis, 🚫JWT | passport react-express water app used: localStorage() to persist the data, which worked.
1: // disclosure: never used redux-persist but found out during react and localStorage that: there's viability (redux-persist) to achieve same thing as localStorage without sending uninvited guests to their machine store
1.1 -> approach problem with redux-persist, 1.2 -> check cookie for existence of unexpired token. 1.3 -> no token ? wipe state clean and navigate to log in