icssc / ZotMeet

Coordinating meetings and so much more
https://zotmeet.com/
MIT License
6 stars 0 forks source link

feat: migrate auth to Lucia V3 and Drizzle #72

Closed KevinWu098 closed 5 months ago

KevinWu098 commented 6 months ago

Summary

  1. Updated our Lucia V2 & Prisma auth system to Lucia V3 and Drizzle
  2. Updated schemas (refer to point 1)
  3. Updated UI for auth pages (very basic, for now)
Screenshot 2024-03-26 at 11 32 08 PM

chrome-capture-2024-2-26 (1)

chrome-capture-2024-2-26 (2)

Progress

Resources:

  1. https://www.youtube.com/watch?v=iouhcbeLe60
  2. https://github.com/edwardspresume/sveltekit-lucia-auth-v3-example/tree/main
  3. https://lucia-auth.com/upgrade-v3/

Future Followup

  1. Reenable Google OAuth once deployments are configured to handle them

Issues

Closes #69 Closes #65

KevinWu098 commented 6 months ago

No idea why the deployment isn't working 🫠

KevinWu098 commented 5 months ago

Code looks good, but I haven't been able to run it because I need to set up the local server.

In this branch, can you add instructions for setting up the local db?

Also, the deployments are failing because oslo (used for password hashing in auth/register/+page.server.ts) is dependent on a native module, which is messing with ESBuild. It's above my head, honestly, but I can't imagine why we'd need native functionality when it's just a SHA-256 hash.

Sorry I've been dormant for so long.

I believe the setup should be the same as described by Adi in #71

https://github.com/icssc/ZotMeet/pull/71/files/9a039e1cb1ed8a0a43f2038007f41cbd8b9d0196#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5

KevinWu098 commented 5 months ago

Deployment worked! Huzzah! I ate your lunch a bit with #73 @MinhxNguyen7 -- needed to remove Prisma for the deployment 🫡

KevinWu098 commented 5 months ago

Looks good, other than the fact that I can't register. I just get this error without anything in the console.

image

Drizzle Studio does seem to indicate that I've set up the tables and DB: image

Well, you're in this try catch:

  try {
    const isEmailAlreadyRegistered = await checkIfEmailExists(form.data.email);

    if (isEmailAlreadyRegistered === true) {
      return setError(form, "email", "Email already registered");
    }

    const userId = generateId(15);
    const hashedPassword = await new Scrypt().hash(form.data.password);

    await insertNewUser({
      ...
    });

    await createAndSetSession(lucia, userId, cookies);
  } catch (error) {
    console.error(error);

    return setError(
      form,
      "email",
      "An error occurred while processing your request. Please try again.",
    );
  }

If you have a moment, would you mind doing some good ol' fashioned console logs to check where the error is originating from? It works on my end, so I can't help too much w/ debugging w/o knowing what line is causing it 😅

KevinWu098 commented 5 months ago

It works now ¯(ツ)/¯.

Just address the data thing, and we can ship it.

must be one of those "off and on again" things :p