I have been wanting to implement a credentials sign in, together with a github sign in and the connection with prismadb. But only the credential sign in doesn't work, if I connect next-auth with the prisma provider. Else it would work weirdly. Although when connected with prisma adapter, and logging in with credentials, there are no errors or warnings printed (it just won't sign in).
[...nextauth].ts:```ts
import { PrismaAdapter } from '@next-auth/prisma-adapter';
import NextAuth, { AuthOptions } from 'next-auth';
import CredentialsProvider from 'next-auth/providers/credentials';
import GithubProvider from 'next-auth/providers/github';
import prisma from './../../../lib/utils/prismadb';
export const authOptions: AuthOptions = {
// Configure one or more authentication providers
adapter: PrismaAdapter(prisma),
providers: [
...
// DEACTIVATE CREDENTIALS FOR NOW
CredentialsProvider({
name: 'Credentials',
credentials: {
username: { label: 'Username', type: 'text', placeholder: 'username' },
password: {
label: 'Password',
type: 'password',
placeholder: 'password',
},
},
async authorize(credentials) {
// Add logic here to look up the user from the credentials supplied
const user = {
id: '0',
name: credentials?.username,
password: credentials?.password,
};
console.log(credentials);
if (user) {
// Any object returned will be saved in `user` property of the JWT
return user;
} else {
// If you return null then an error will be displayed advising the user to check their details.
return null;
}
},
}),
],
...
};
export default NextAuth(authOptions);
The signIn.tsx (sign in page) (ignore the styling, etc.) can be found here: https://paste.ofcode.org/vR2uJZ2AJ4X3vwddXvm62T