Uzywam next-auth
do logowania. Na localhost:3000
wszystko dziala natomiast na codesandbox.io otrzymuje błąd.
https://ngjvt6-3000.csb.app/api/auth/signin?csrf=true i pozniejsze logowanie z Credentials takze nie dziala logowanie z
tutaj jest moje repozytorium:
https://codesandbox.io/p/github/arturnowakowski2015/nextapps/main
tak wyglada moj provider:
const handler = NextAuth({
providers: [
CredentialsProvider({
name: "Credentials",
credentials: {
username: { label: "Username", type: "text", placeholder: "Username" },
password: { label: "Password", type: "password" },
},
async authorize(credentials, req) {
const user = await res.json()
alert(credentials); ///to wogole sie nie wywoluje
try {
const user = User.filter((t) => {
return t.email === credentials.email && t;
})[0];
if (user) {
const isPasswordCorrect = await bcrypt.compare(
credentials.password,
user.password
);
if (isPasswordCorrect) {
return user;
} else {
throw new Error("Wrong Credentials!");
}
} else {
throw new Error("User not found!");
}
} catch (err) {
throw new Error(err);
}
},
}),
],
pages: { error: "/dashboard/login" }, session: {
strategy: 'jwt'
}
});