Use nextauth with supabase email and password

I know this is not a recommended practice. But im trying to setup nextauth to work with supabase's
const { data, error } = await supabase.auth.signInWithPassword({
email: credentials?.email,
password: credentials?.password,
});
const { data, error } = await supabase.auth.signInWithPassword({
email: credentials?.email,
password: credentials?.password,
});
I have created the CredentialsProvider but once I submit the user and password, I get redirected propperly but the user's logged in session isn't persisted.
CredentialsProvider({
name: "Login",
credentials: {
email: { label: "email", type: "email", placeholder: "jsmith" },
password: { label: "Password", type: "password" },
},
async authorize(credentials, req) {
if (!credentials?.email || !credentials.password) return null;
const { data, error } = await supabase.auth.signInWithPassword({
email: credentials?.email,
password: credentials?.password,
});

if (error) throw Error(error.message);
if (!data.user) throw Error("No user found for this credentials");
return data.user;
},
}),
CredentialsProvider({
name: "Login",
credentials: {
email: { label: "email", type: "email", placeholder: "jsmith" },
password: { label: "Password", type: "password" },
},
async authorize(credentials, req) {
if (!credentials?.email || !credentials.password) return null;
const { data, error } = await supabase.auth.signInWithPassword({
email: credentials?.email,
password: credentials?.password,
});

if (error) throw Error(error.message);
if (!data.user) throw Error("No user found for this credentials");
return data.user;
},
}),
This is the provider im currently using, how can I extend the t3-stack in order to get this working?
1 Reply
BarisP
BarisP3y ago
Next auth only supports jwt for the credential login, doesn't support the server session way.
Want results from more Discord servers?
Add your server