Code Monkey home page Code Monkey logo

Comments (18)

markstory avatar markstory commented on August 22, 2024 1

You DB column is probably too short, bcrypt hashes are much longer than sha1's. If you are using a fixed length column they will be truncated.

from app.

lorenzo avatar lorenzo commented on August 22, 2024

what is not working exactly? Password hasher were recently changed in 3.0, you may want to take a look at the auth tutorial again and perhaps manually reset passwords for your current database if it is an option for you. In the future, please open tickets in cakephp/cakephp

from app.

archanavhire avatar archanavhire commented on August 22, 2024

I am not able to login after submit on login button, always going in else part.
I am giving right username and password.please look in to my auth login code.
I followed all steps for authentication.
https://gist.github.com/archanavhire/1460ebc16a7510d8d589

from app.

lorenzo avatar lorenzo commented on August 22, 2024

Can you debug if the hashed password match? Go into the BaseAuthenticate class and debug the hashed password value and compared to the one in the database

from app.

archanavhire avatar archanavhire commented on August 22, 2024

I found the bug, which is in FormAuthenticate class. _checkFields of FormAuthenticate class return false because of username field(In my form it is email). but I already mention in app controller for email field instead of username.
Still not able to fix this bug.

from app.

ADmad avatar ADmad commented on August 22, 2024

The problem was in your config

$this->Auth->config('authenticate', ['Form'=>['username'=>'email','password'=>'password']]);

you are missing the fields key. It should be

$this->Auth->config('authenticate', ['Form'=>['fields' =>['username'=>'email','password'=>'password']]]);

from app.

archanavhire avatar archanavhire commented on August 22, 2024

problem is in $this->passwordHasher()->check($password, $result[$fields['password']]) function which is in BaseAuthenticate class.
function is returning false even if I got result array.

from app.

lorenzo avatar lorenzo commented on August 22, 2024

Can you go into the hasher code and compare what it produces versus what you have stored in the database?

from app.

archanavhire avatar archanavhire commented on August 22, 2024

Yes I did it and I found record in database. It is also returning result in $result variable.
But after that its again checking passwordHasher which is returning false.

from app.

lorenzo avatar lorenzo commented on August 22, 2024

you're still not answering my question, how does the password stored in your database compare to what the password hasher is producing?

from app.

archanavhire avatar archanavhire commented on August 22, 2024

I stored password in blowfish hash code which is 50 char.
App\Model\Entity\User.php

hash($password); } } ?>

from app.

lorenzo avatar lorenzo commented on August 22, 2024

can you paste here the password stored in your database and the one that is checked in the password hasher class?

from app.

archanavhire avatar archanavhire commented on August 22, 2024

In database :
$2y$10$6dab8w1rJ0RP411hkl.B8OBwzwaK0ZgnZoR7/XjmBPo
in result variable:
[password] => $2y$10$6dab8w1rJ0RP411hkl.B8OBwzwaK0ZgnZoR7/XjmBPo

from app.

archanavhire avatar archanavhire commented on August 22, 2024

ok, I got it.
In $this->passwordHasher()->check($password, $result[$fields['password']]) function
$password is in simple text and $result[$fields['password']] is hashed so that its returning false.

from app.

lorenzo avatar lorenzo commented on August 22, 2024

Both passwords are the same, how come the password checker returns false then? Can you help us debug that?

from app.

lorenzo avatar lorenzo commented on August 22, 2024

If you are using the laters CakePHP 3.0, please use SimplePasswordHasher instead of Blowfish

from app.

archanavhire avatar archanavhire commented on August 22, 2024

As you suggested me, I switched from Blowfish to SimplePasswordHasher. But still authentication is not working because password is not matching.following code returning false.
password_verify($password, $hashedPassword);

password return by hasher :
'$2y$10$dDcxwWtDJVYnRfNX.wIBJuQdokyX65ZpaQCcqvQSQOiGH7yf7HMAG'
password in my db:
'$2y$10$HJ9urHeVBzXezb0Hh13AJeU3PquK2f4yLIrl9bHNVWl'

My updated gist link is:
https://gist.github.com/archanavhire/842266d5953c0df413f2

from app.

archanavhire avatar archanavhire commented on August 22, 2024

Thank you very much. Now its working.
:)

from app.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.