923 viewsNext Amazona

Hi,

I’m following the Next Amazona course on youtube right now and I’m having trouble with the login API. I’ve followed all the instructions in the video and checked my code against your GitHub repository (Video 13), but I’m still getting “Illegal Arguments: string, undefined” when I try to login in with the username and password in the browser.

I think that the problem has something to do with either bcryptjs or CredentialsProvider from next auth, but I’m not sure.

I added a console.log(credentials) after

CredentialsProvider({
      async authorize(credentials) {

and got

[Object: null prototype] {
  redirect: 'false',
  email: '[email protected]',
  password: 'asdfgh',
  csrfToken: '54134bf42a24e36fc264da3d7e8759724cdfe74f4c2dd5f5cd5ae7fb5fbda7a5',
  callbackUrl: 'http://localhost:3000/login',
  json: 'true'
}
already connected
not disconnected

so I know that the credentials are being logged successfully. I think the problem is in comparing the credentials password and the user password.

This is just my current theory though. If you have any suggestions on how to fix this issue please let me know!

Bassir Answered question October 13, 2022

hello there,

the issue is in getting password from db. use console.log there to see what you get from db to compare with input form password.

read this please:

https://stackoverflow.com/questions/44871280/error-illegal-arguments-string-undefined-and-stop-server-in-node-js

Bassir Answered question October 13, 2022