Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: migrate auth to Lucia V3 and Drizzle #72

Merged
merged 75 commits into from
Mar 31, 2024
Merged

Conversation

KevinWu098
Copy link
Member

@KevinWu098 KevinWu098 commented Mar 14, 2024

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

  • Setup local DB
  • Update, Migrate schemas
  • Migrate login/registration
  • Actual functionality
  • Oauth

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
Copy link
Member Author

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
Copy link
Member Author

KevinWu098 commented Mar 27, 2024

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

Copy link
Member

@MinhxNguyen7 MinhxNguyen7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

src/routes/availability/+page.svelte Show resolved Hide resolved
src/routes/+layout.svelte Show resolved Hide resolved
src/lib/db/authUtils.server.ts Show resolved Hide resolved
@KevinWu098
Copy link
Member Author

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 KevinWu098 requested a review from MinhxNguyen7 March 28, 2024 01:54
Copy link
Member

@MinhxNguyen7 MinhxNguyen7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works now ¯_(ツ)_/¯.

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

@MinhxNguyen7 MinhxNguyen7 removed the request for review from adi-lux March 31, 2024 05:58
@KevinWu098
Copy link
Member Author

It works now ¯_(ツ)_/¯.

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

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

@KevinWu098 KevinWu098 requested a review from MinhxNguyen7 March 31, 2024 06:01
Copy link
Member

@MinhxNguyen7 MinhxNguyen7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

             __/___            
          _____/______|           
  _______/_____\_______\_____     
  \              < < <       |    
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@MinhxNguyen7 MinhxNguyen7 merged commit 3b19f0e into main Mar 31, 2024
2 checks passed
@KevinWu098 KevinWu098 deleted the kw/69-auth-drizzle branch October 17, 2024 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix auth to work with Drizzle Lucia should no longer use Prisma
3 participants