portapipe / Login-GroceryCrud

A Login/Logout system for GroceryCrud (codeigniter).
32 stars 26 forks source link

Add user with password as MD5 hash #14

Open garduino opened 6 years ago

garduino commented 6 years ago

With the example for the user's CRUD, GC always store the password in clear text, even when have the MD5 configured.

How to store the hash instead the clear text password?

portapipe commented 6 years ago

Hi, the code provide a way to encrypt the password for the login check. The database insert is managed by you. I've added an example to the wiki on how to manage md5 password creation: https://github.com/portapipe/Login-GroceryCrud/wiki/Manage-the-users

Test it and let me know :)

garduino commented 6 years ago

Hi! and thanks you very much for your quick answer!

I was trying some sort of "hardcoding" assuming that always I will use MD5, at this way:

$crud->callback_before_insert(md5('password'));

but not worked.

Your suggestion is not working neither for me, may be because I do not have the users() function inside the Login controller, should be there?

Note: I also tried to move the users() function inside the Login.php controller and also the passwords are stored as clear text.

Also I do not understand the function encrypt_password_callback() and where it should be pasted.

I'm sorry, I'm still newbie with CI, GC et all and need to learn :)

portapipe commented 6 years ago

$crud->callback_before_insert(md5('password'));

You have to follow this documentation strictly:

https://www.grocerycrud.com/documentation/options_functions/callback_before_insert

garduino commented 6 years ago

Thanks for your answer.

I think that in https://github.com/portapipe/Login-GroceryCrud/wiki/Manage-the-users

were says:

If you need to use MD5 encryption, add this just above the $output row:

$crud->callback_before_insert(array($this,'use_md5_password'));

shoud says:

If you need to use MD5 encryption, add this just above the $output row:

$crud->callback_before_insert(array($this,'encrypt_password_callback'));

At this way it seems to work.