Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with auth.attemp password Password does not match error #500

Closed
eriasu opened this issue Mar 7, 2017 · 10 comments
Closed

Problem with auth.attemp password Password does not match error #500

eriasu opened this issue Mar 7, 2017 · 10 comments

Comments

@eriasu
Copy link

eriasu commented Mar 7, 2017

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

@eriasu
Copy link
Author

eriasu commented Mar 7, 2017

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

@RomainLanz
Copy link
Member

Hey @eriasu !

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

@eriasu
Copy link
Author

eriasu commented Mar 7, 2017

@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')
  }

@thetutlage
Copy link
Member

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

@eriasu
Copy link
Author

eriasu commented Mar 8, 2017

Sorry for the delay https://github.com/eriasu/AdonisTest

@eriasu
Copy link
Author

eriasu commented Mar 8, 2017

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

@thetutlage
Copy link
Member

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')

@eriasu
Copy link
Author

eriasu commented Mar 9, 2017

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

@thetutlage
Copy link
Member

Closing the issue

@lock
Copy link

lock bot commented Mar 11, 2020

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.

@lock lock bot locked and limited conversation to collaborators Mar 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants