daily log 10.30.20

1 minute read

OK what just happened:

PROBLEM: I realized I wasn’t actually checking (or validating!) my password on the backend, meaning I could sign in with any email.

SOLUTION: Re-implement the validators I made while working on ecomm catcart for umjs

PROBLEM: They need to talk to my DB and I’m already talking to my DB elsewhere

SOLUTION: Pull DB out into its own module to be required by all the files that need it

PROBLEM: Still not working

SOLUTION: Put the validator directly into the index.js page

HOORAY IT’S WORKING!!

But now the index.js page is huge and messy and does this mean I’m going to have to do this for EVERY SINGLE VALIDATOR!?

PROBLEM: I still have no idea why this isn’t working

SOLUTION: CONSOLE LOG ALL THE THINGS!!

PROBLEM: See that while my email is getting sent with mixed lowercase and capitalization, it is getting stored and “validated” as all lower case

SOLUTION: remove the “normalize” function in my email validator

HOORAY THIS WORKS!!!

But omg oh no all the emails I’ve already stored in my DB have mixed cap and loewrcase because I wasn’t using the validators on the input end

SOLUTION: Use the validators on the input end!!


Attempting to use state with localstorage

import './App.css';

import Login from './Login';
import Account from './Account';

require('dotenv').config();


const useStateWithLocalStorage = (localStorageKey) => {
  const [value, setValue] = useState(
    localStorage.getItem(localStorageKey) || ''
  );
 
  useEffect(() => {
    localStorage.setItem(localStorageKey, value);
  }, [localStorageKey, value]);
 
  return [value, setValue];
};

function App() {

  const [page, setPage] = useStateWithLocalStorage('pp-current-page')
  // if (page !== "home") {
  //   setPage('home')
  // }
  // setPage('home')
  console.log('PAGE', page)
  return (
    <div>
    <h1>MONGO PARTY!</h1>
    <Login />
    </div>
  );
}

export default App;