help prisma error
i'm a beginner with better-auth i have an error for the signup and i don't know why even though the prisma schema is well defined.
the password field is filled in correctly in the form
Please can you help me to set up a login and signup

75 Replies
show the auth client call

the part where you call signIn
for login and singup


I dont see anything immediately wrong here
show your prisma schema
user is not supposed to have a password field
it should be on account

yeah your schema is wrong
Schema

this is an example schma
does your's look like this?
yes, but with a password field in the User
remove that
if I delete the password field in the prisma schema as the user creates an account and login, how do I do that?
what do you mean?
a user will have a account linked to them
that would hold their password or oauth info
I will authenticate by email and password
yea that would be a credential account in your account table
user table doesnt need to have password
so if there's no password, how does the user log in?
the password is stored in the linked account with user
its created when you sign up
okay, I'll send you the repo link so you can check it out.
and show me how it works
just remove the password filed from user
do prism migrate
and it would work
but I keep the password on the front side of the form and the data sent.
oh god
can you just do what I say and tell me if it works or not
remove password filed from user table in your prisma schema
then migrate your prisma db
and try
All right, I'll go like this and let you know
yeah once it works, then ask whatever you want to know
okay, I'm a boring junior but thanks
here's the error I get when I try to signup


why is it even asking for user.password, it should not even exist
do this, I will take a look
but in the form there is always the password field but if I remove this field the user can no longer register or log in or I'm wrong
i think you are missing fundamental details about how auth works
you take the values from form
pass them into signUp.email
those get send to better auth
and it handles the rest
i've already made a poc with next-auth but with better-auth i have the impression of not controlling authentication
https://github.com/AristideDongo/poc
repo link
GitHub
GitHub - AristideDongo/poc
Contribute to AristideDongo/poc development by creating an account on GitHub.
give me like 5 min to check
no problem
you just need to do a migration
then run your app and it should work



it works
before this fix your tabels
make sure your schema has all these fields defined in this schmea
the connection goes through but I can't get the res even though I'm in the browser's network and localstorage
did you even read what I said
I just ran did a migration and it worked on my local
do it on your machine and it will work for you
it works on my local computer
ok so when it doesnt work
ah okay but in my case the token is returned in the cookie
it is also returned as a cookie
here

ah okay, can you help me with the context?
?
what context?
I see thank you
???
I wanted to create a context to receive the token and be able to use the role throughout the app.
the session token?
yeah
why would you want to be able to access that
its in your cookies, its http only, you will use the auth checks on your server to verify auth status
ah right,but why when I try to put the role I get an error

Database | Better Auth
Learn how to use a database with Better Auth.
okay
better-auth use middleware for token ?
what?
what do you even mean
to protect routes as in next-authto protect routes as in next-auth
in your middleware file, use
auth.api.getSession
if no session exists redirecti don't have middleware how to do this in better-auth
its a nextjs feature
its a very basic and universal feature, please go and learn that
i know but i'm not used to backend in nextjs
so go and learn that
do you have an example of app faire in better-auth? I want to check something because the better-auth documentation is difficult to understand.
GitHub
better-auth/demo/nextjs at main · better-auth/better-auth
The most comprehensive authentication framework for TypeScript - better-auth/better-auth
I'm back please, can you tell me how to recover a user? because in the better-auth doc I don't see it
getSession?
yes, but when I do that I get nothing
are you passing in the headers?
const session = await auth.api.getSession({
headers: await headers()
})
log the headers and check if the cookie is there
I found the error
it's my middleware but it doesn't work
is your middleware running on the routes you want it to'
now that's correct?
it is a nextjs thing, I dont use nextjs enough to answe that
ah okay