lucia-auth / lucia

Authentication, simple and clean
https://lucia-auth.com
MIT License
9.46k stars 485 forks source link

[Bug]: createUser method not working #1344

Closed visualcohol closed 9 months ago

visualcohol commented 9 months ago

Package

lucia-auth

Describe the bug

I followed the tutorial "Sign in with username and password" - created the DB tables, created an extra table for the additional field, and when I try to programmatically create a user it creates a foreign key error. It basically doesn't insert the user ID into the user table first, so everything else fails. If I manually copy the user ID over to user table, it works.

Im using hyper-express as the server and postgressql 16 as DB

thanks

https://youtu.be/gpNINYItckk

lucia
pilcrowonpaper commented 9 months ago

What error are you getting?

noxify commented 9 months ago

Based on the attached YouTube video, the error is:

image
pilcrowonpaper commented 9 months ago

You seem to have 2 user tables?

visualcohol commented 9 months ago

The tutorial said, I need 3 tables - user, user_key, user_session - I added an extra username field, when I started to work with the signup, an error told me I need to create a auth_user table, or else. So which table is redundant?

pilcrowonpaper commented 9 months ago

You need a user, key and session table - 3 total listed in the docs. How you name them is up to you, assuming you're using the postgres() adapter

visualcohol commented 9 months ago

Oh, my mistake - I was following the main page tutorial for naming tables ("user"), but the postgres adapter docs user field is named differently ("auth_user"), so I mixed up things. Thanks!

image