Error 500 when performing an authentication request with Adonisjs

Asked

Viewed 33 times

0

I have a Sessioncontroller, which is the method that performs the user authentication process in the application.

class SessionController {
  async store ({ request, response, auth }) {
    const data = request.all()
    const token = await auth.attemp(data.email, data.password)
    return token
  }
}

My Routes.js, tbm has the instance of this method for API mapping:

Route.post('/sessions', 'SessionController.store')

The user data is already in the database, the problem is that when I perform the request, returns me an error 500.

I debugged the application, and it seems that the application does not run after the line const token = await auth.attemp(data.email, data.password).

With no idea what it could be!

1 answer

1

Like the status code is 500, probably an error in the code, see:

You wrote the method attempt incorrectly. In your code, there is this excerpt:

const token = await auth.attemp(data.email, data.password)

According to the documentation, the correct is:

const token = await auth.attemp(data.email, data.password)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.