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

Storing data #580

Closed
Iamscalla opened this issue Jul 1, 2017 · 12 comments
Closed

Storing data #580

Iamscalla opened this issue Jul 1, 2017 · 12 comments

Comments

@Iamscalla
Copy link
Contributor

I don't know if I have to attribute this issue to codeigniter or a something else.

I tried to save an hashed password using the php hash function, but it truncates the first 4 char of the hashed password. mind you, I applied same rule regarding using that function. I applied same function in codeigniter 3 it worked well.

@ghost
Copy link

ghost commented Jul 2, 2017

The same thing happened to me using the model->insert method.

@Iamscalla
Copy link
Contributor Author

the image below shows what am talking abt

ellor fw

@daylightstudio
Copy link
Contributor

daylightstudio commented Jul 2, 2017

This area in the protectIdentifiers method code looks suspicious to what may be causing your issue:
https://github.com/bcit-ci/CodeIgniter4/blob/develop/system/Database/BaseConnection.php#L1061-L1073

@lonnieezell
Copy link
Member

I've run into this previously and thought I had it conquered but perhaps not :) can you share the code you're using so I can recreate? I'm pretty sure it was happening previously due to it be double escaped.

@Iamscalla
Copy link
Contributor Author

Iamscalla commented Jul 3, 2017

below is the code
`
$password = '123456';

$usermodel = new UserModel();

$hashpass = \App\Libraries\Auth\Password::hashPassword($password);
// Update user password
$pdata = [
'user_password' =>$hashpass ,
];
if (! $usermodel->update($user['user_id'], $pdata))
{
$this->error = $usermodel->error()['message'];
//$this->error = 'Unknown error encountered';
return false;
}
`

@lonnieezell
Copy link
Member

A couple of assumptions, please tell me if I'm wrong:

  1. UserModel doesn't do anything extra and is simply extending CodeIgniter\Model.
  2. hashPassword library basically uses PHP's password_hash() function with a BCRYPT as the type?

What does the hash look like after it's generated? Is it the same as in your image above?

@Iamscalla
Copy link
Contributor Author

yea its same as the above image.

i even ran a the regular query without the model, same thing

@lonnieezell
Copy link
Member

Ok, thanks for the confirmation. I will try to look into this tonight, but with a Holiday here in the states, and a sick kid, it might not happen for a couple of days.

@Iamscalla
Copy link
Contributor Author

oh sorry about the kid, well project is been used for is not going live soon, so it cool

@lonnieezell
Copy link
Member

@chistel Pull down the latest code and let me know if you run into any issues. I managed to get a bit of free time before calling it a day here.

I've reworked how named bindings works with the Query object and this should help, but still feels a touch hacky. Tests pass but I don't have a full-fledged app yet to test it under a variety of use-cases.

@Iamscalla
Copy link
Contributor Author

(y) nice one, it worked absolutely well @lonnieezell

@lonnieezell
Copy link
Member

Awesome. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants