Skip to content

Auth with custom fields #1306

Answered by thetutlage
rafaelcascalho asked this question in Help
Discussion options

You must be logged in to vote

Simply fetch the user yourself from the database, verify the password and then use auth.login method. This is how it should roughly look like.

import Hash from '@ioc:Adonis/Core/Hash'

const user = await User.query().where().firstOrFail()
const isValid = await Hash.verify(user.password, passwordSubmittedInForm)

if (!isValid) {
  // return error
}

await auth.login(user)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by rafaelcascalho
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants