How to change the Adonisjs hash to md5?

Asked

Viewed 214 times

0

Hello, I am developing an api on top of a legacy project used by other systems, and I intend to perform an authentication using md5 instead of bcrypt to compare the password only.

There is already a table of users with email and password (on md5).

In my controller everything is already working taking away the fact of await auth.attempt(usuario, senha) compare password using bcrypt and not md5 as accurate.

I tried to install the md5 package and change the settings HASH_DRIVER but unsuccessfully, the question is I don’t understand where I do this kind of configuration, and if it’s possible, I’ve searched the internet since yesterday and nothing yet, I’m waiting for a light where I should search.

  • I think this library can help you: https://www.npmjs.com/package/adonis-md5hash

  • @Bins unfortunately it is outdated and I am not able to implement in version 4.1

  • You will probably have to recreate the method attempt manually, given that it is very unlikely that Adonis will ever provide you with this natively, since the md5 is not safe for that purpose.

  • @Luizfelipe you could pass me the way to recreate the method Attempt ?

  • You will have to create the logic of login manually... Select the user table through the user name and then compare passwords.

  • @Luizfelipe understand, is that with attemp I received the authentication token, I will see how to generate it

  • 1

    Just use the auth.generate after carrying out the checks.

  • @Luizfelipe really I was going the wrong way, I performed a consultation manually and in the success generating the token, at first it is precise, grateful.

Show 3 more comments
No answers

Browser other questions tagged

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