Core: Problem with auth.attemp password Password does not match error

Created on 7 Mar 2017  路  10Comments  路  Source: adonisjs/core

Hi i have a problem when i want to verify the hash password the response is always false and i cant loging i send to the console the plaintext, the hash password and use the verify function in the Hash library when i create the user the verify send true when i want to login the verify send false
screenshot from 2017-03-07 13-41-15

Most helpful comment

You are hashing the password twice. Their is hook inside User model which hashes the password and you are doing it manually too inside the controller. Remove the controller one.

It needs to be

user.password = request.input('password')

All 10 comments

screenshot from 2017-03-07 14-10-08

Hey @eriasu !

May you copy/paste some code where you're using auth.attempt()?

@RomainLanz no problem

* doRegister(request, response){
      const user = new User()
      user.username = request.input('name')
      user.email = request.input('email')
      user.password = yield Hash.make(request.input('password'))
      yield user.save()

      yield response.sendView('register')
  }

 * login(request, response) {
        const email = request.input('email')
        const password = request.input('password')

        const login = yield request.auth.attempt(email,password)
        if(login){
          response.send('Logged In')
          return
        }
      response.unauthorized('Invalid Credentails')
  }

Kind of weird. Mind creating a sample repo with the same code I can use to reproduce the issue?

i even test passing here the passwod for testing and making sure that the plaintext was compare with the hash but the same error =/ or maybe a made a huge mistake
screenshot from 2017-03-08 08-21-48

You are hashing the password twice. Their is hook inside User model which hashes the password and you are doing it manually too inside the controller. Remove the controller one.

It needs to be

user.password = request.input('password')

yeah it was that stupid me srry for the trouble thanks for the help!

Closing the issue

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

itsg2jakhmola picture itsg2jakhmola  路  3Comments

dezashibi picture dezashibi  路  4Comments

GianCastle picture GianCastle  路  3Comments

blendsoft picture blendsoft  路  3Comments

begueradj picture begueradj  路  3Comments