You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi all, I am not sure if this is a bug or I am configuring something wrong.
I have 3 providers, Google, Magic link with Resend, and the old good fashion email and password with Credentials.
The first two work without any problem out of the box, but the credentials do not save the session in the database, only creating the cookie, which disappears after refreshing the page.
Using the signIn() function from @auth/sveltekit/client
My auth.ts file looks like this, leveraging auth.js to save the session in the database with the Postgres adapter. It works perfectly with Google and Resend providers but not with credentials:
exportconst{ handle, signIn, signOut }=SvelteKitAuth({trustHost: true,adapter: PostgresAdapter(pool),secret: process.env.AUTH_SECRET,providers: [Resend({from: "chatdiamond@ctwhome.com",name: "Chat Diamond",}),Google,Credentials({name: 'Credentials',asyncauthorize(credentials){const{ email, password }=credentials;constresult=awaitpool.query('SELECT * FROM users WHERE email = $1',[email]);constuser=result.rows[0];if(user){constisValid=awaitbcrypt.compare(password,user.password);if(isValid){console.log('User authorized',user);return{id: user.id,email: user.email};}}console.log('User authorization failed');returnnull;}})],asyncsignIn({ user }){if(user){returntrue;// THIS TRIGGERS AND RETURNS TRUE, but the session callback doesn't trigger}returnfalse;},callbacks: {asyncsession({ session, user }){if(user){session.user.id=user.id;session.user.email=user.email;}returnsession;}
...
}
Using the strategy database breaks the Resend and Google Providers
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all, I am not sure if this is a bug or I am configuring something wrong.
I have 3 providers, Google, Magic link with Resend, and the old good fashion email and password with Credentials.
The first two work without any problem out of the box, but the credentials do not save the session in the database, only creating the cookie, which disappears after refreshing the page.
Using the signIn() function from @auth/sveltekit/client
My auth.ts file looks like this, leveraging auth.js to save the session in the database with the Postgres adapter. It works perfectly with Google and Resend providers but not with credentials:
Using the strategy database breaks the Resend and Google Providers
Can someone point out what would be wrong?
Many thanks!
Beta Was this translation helpful? Give feedback.
All reactions