I think there is something wrong with my setup, the password hash in my database is using bcrypt, as per reading on the laravel documentation, laravel santcum should be using Hash::make which also use bcrypt. However, when I test it on tinker to do not get a good result.
`/opt/lampp/htdocs/cbit_intranet_be$ php artisan tinker Psy Shell v0.10.6 (PHP 8.0.1 — cli) by Justin Hileman
Hash::check("Welcome123!", "$2y$10$PR6bKMXSuNhKdk6u6dVuA.wzCq1HmY3BZdx27Tx4BiZ9e5LFVYpr2"); <warning>PHP Warning: Undefined variable $PR6bKMXSuNhKdk6u6dVuA in Psy Shell code on line 1</warning> => false password_verify("Welcome123", "$2y$10$PR6bKMXSuNhKdk6u6dVuA.wzCq1HmY3BZdx27Tx4BiZ9e5LFVYpr2"); <warning>PHP Warning: Undefined variable $PR6bKMXSuNhKdk6u6dVuA in Psy Shell code on line 1</warning> => false `
Any ideas?
I figured out the issue...apparently password field is a column that should not be renamed. I updated my column on the database from hashedPassword to password and updated my SysUser Model's hashedPassword to password.
As in
id | user_id | email_address | password | enabled | date_created | date_updated | isADConnected | resetPassOnNextLogon | date_passwordUpdate | remember_token |
---|---|---|---|---|---|---|---|---|---|---|
1 | 1 | [email protected] | $2y$10$PR6bKMXSuNhKdk6u6dVuA.wzCq1HmY3BZdx27Tx4BiZ9e5LFVYpr2 | 1 | 2021-03-12 05:45:05 | 2021-03-12 01:38:57 | 1 | 0 | 2021-03-12 05:45:05 |
SysUser Model: protected $casts = [ 'id' => 'integer', 'user_id' => 'integer', 'email_address' => 'string', 'password' => 'string', 'enabled' => 'boolean', 'resetPassOnNextLogon' => 'boolean', 'remember_token' => 'string', 'isADConnected' => 'boolean', 'date_created' => 'datetime', 'date_updated' => 'timestamp' ];
public function getHashedPassword() { return $this->password; }
public function setHashedPassword(string $password) {
$this->password = $password;
}
And on my Login Controller: if (Auth::attempt(['email_address' => $request->email_address, 'password' => $request->password, 'enabled' => 1], $request->remember)) {
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community