Next-Auth CredentialsProvider not working as intended

Not sure how to use CredentialsProvider properly
11 Replies
domi?
domi?OP3y ago
This is my code for the autorize function:
authorize: async credentials => {
const user = await prisma.user.findFirst({
where: {
key: '...'
}
});

console.log('RETURNING USER');
console.log(user);

return user;
}
authorize: async credentials => {
const user = await prisma.user.findFirst({
where: {
key: '...'
}
});

console.log('RETURNING USER');
console.log(user);

return user;
}
The user exists, it is returned, but the session state is never updated. What I'm trying to achieve, is that a user can log in with an oauth provider normally, or by providing a key (thats like a backup login) Each user in the db has a additional filed called "key" where their secret login key is stored But the session is never updated, it's still null, even though I'm returning the user object.
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
domi?
domi?OP3y ago
no I'm using postgres & prisma for my db don't they contradict each other?
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
domi?
domi?OP3y ago
hm I see, is there a solution to achieve what I'm trying to do?
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Zero
Zero3y ago
Yeah next-auth is super opinionated about using password credentials for good reasons but still quite annoying So you have to use the jwt strategy to even use it and then you have to deal with the credentials func and the session/token funcs too
domi?
domi?OP3y ago
if I turn the strategy to jwt, will I still be able to use oauth logins?
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
domi?
domi?OP3y ago
in terms of underlying infrastructure, what are the sort of things that will change when I switch to a jwt strategy? Like will I still have the User information saved to the db? Where will sessions be stored? Is there a part of the docs that explain this well? (couldn't find any good resource that compared the two strategies)
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server