Sign in with credentials provider and custom login form not working #3534
Answered
by
balazsorban44
mbpictures
asked this question in
Help
-
Description 🐜I've created a custom credentials provider and a custom login form, but I always get redirected to the default login form. Is this a bug in your own project?Yes How to reproduce ☕️Client: await signIn("credentials", {
redirect: false,
email: email,
password: password
}); Server: export default NextAuth({
secret: process.env.NEXTAUTH_SECRET,
providers: [
CredentialsProvider({
name: "email",
id: "login",
credentials: {
email: { label: "E-Mail", type: "email", },
password: { label: "Password", type: "password" }
},
async authorize(credentials, req) {
console.log("TEST");
const user = await prisma.adminUser.findUnique({
where: {
email: credentials.email
}
});
const checkPassword = await compare(credentials.password, user.password);
if (!checkPassword) return null;
return user;
}
}),
CredentialsProvider({
name: "api",
id: "apiKey",
credentials: {
key: { label: "Api-Key", type: "text", },
},
async authorize(credentials, req) {
const key = await hashPassword(credentials.key ?? req.headers["Api-Key"]);
const apiKey = await prisma.adminApiKeys.findUnique({
where: {
key: key
},
include: {
user: true
}
});
return apiKey.user;
}
})
],
}) Screenshots / Logs 📽No response Environment 🖥NEXTAUTH_URL=https://localhost:3000/api/admin/auth Contributing 🙌🏽No, I am afraid I cannot help regarding this |
Beta Was this translation helpful? Give feedback.
Answered by
balazsorban44
Dec 28, 2021
Replies: 2 comments 3 replies
-
you overrode the |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
mbpictures
-
Can anyone help me with similar issue: #4318 << please help me on this link |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you overrode the
id
. None of the providers you registered on the server matchescredentials