adonisjs / auth

Official Authentication package for AdonisJS
https://docs.adonisjs.com/guides/auth/introduction
MIT License
187 stars 65 forks source link

fix(mixins): receive a function instead of the hash module directly #230

Closed RomainLanz closed 6 months ago

RomainLanz commented 6 months ago

Hey there! 👋🏻

This PR changes the argument of withAuthFinder.

Before, we were receiving directly the hash module.

const AuthFinder = withAuthFinder(hash.use('scrypt'), {
  uids: ['email'],
  passwordColumnName: 'password',
})

This was causing some issues if you used the mixin before the app boot (i.e, in a command).

Moving to a function-based approach makes it work since we are delaying the access to hash.

const AuthFinder = withAuthFinder(() => hash.use('scrypt'), {
  uids: ['email'],
  passwordColumnName: 'password',
})

[!NOTE] Preset and documentation must be updated to reflect the change.

thetutlage commented 6 months ago

Looks good. Can you please update the preset and the docs both?