I am working on change password function in laravel4 . I got stuck into one point that how to match hashed password on database with the new password we enter.
I know this that laravel4 Auth produces new hash value every time for the same input .
Please help me on this .
Thanks.
The question is unclear why do u want match the new password with old ?
But to check the password you can do
Hash:check($entered_old_password, $password_from_db);
*$password_from_db - would be hashed password.
I typically have a form with 3 text inputs, 1 for old password and 1 for new password and the last one for new password confirmation.
On submit check if the old password matchs if so update the user's password with the new one.
You can also use Eloquent Accessor & Mutators to Hash password every time it is set so you don't have to do that in multiple places
[http://laravel.com/docs/eloquent#accessors-and-mutators]
Is that what you are looking for?
Related
I need to hash and salt user entered passwords and store it in the database. I also need to validate the hashed & salted password when a user login to the site.
I read from the following adobe blog by David Byers:
https://coldfusion.adobe.com/2020/04/best-practices-secure-password-storage-coldfusion/
This blog explains and gives sample codes on how to hash and add salt to user password with screen shots.
My First question is:
Do I need to create two columns in my database table to store the hashed password and the salt just like how he explained in this blog?
If yes,
than my second question is:
How do I validate user password that's been hashed and salted? If the values of hashed and salted password are separated in two columns like that do I have to concatenate the two strings when validating?
My last question is:
How to authenticate/validate user password when the password is hashed and salted? is there any codes example I can see? Thank you
Is it possible to take input of password from user in hidden form in sql?
As we enter any character immediately it should get replaced by * .
When we try to connect with oracle as we can't see our password like that way i want to take input from user.
How I can get email from password_resets tabled based on token? Because I need remove email field from reset password view.
I tried DB::table() but its still returns empty items array.
What I'm doing wrong?
you can not select email using token. Because token is stored with Hashing, and every hash string generated from same token is different.
Laravel decrypt token by select it using email and then compare it with the plain token like this
if (Hash::check('plain_token', $hashed_token))
{
}
you can not do vice-versa.
hope, now you have clear the concept of reset password.
you can delete entries manually from database.
I have 2 database tables consisting of 2 different user types.
Users and Players.
Players is with user data from in-game plugin where passwords are BCrypted.
Users one is empty and is intended to store the user info from the Players table.
I am comparing the usernames and passwords.
The problem is that from the user input in the website get plain text password, and from the other table the passwords are already bcrypted and the Laravel bcrypt does not match the bcrypted cipher from Players table.
What are my options to compare the passwords in order to confirm that this is the user trying to log in.
In-game plugin cipher:
$2a$10$lpVYpSJ4O6Mt03eItJeipOWR8LGHP8dgk4a09.e6BFKVoYNAgjz86
Laravel plain text bcrypted:
$2y$10$yZoq3xBsfow49pL6UyGD2.5NKlmHOmfnCFc9JD5ZjDz3pf5K1XMhG
Both passwords are the same.
Try using Hash::check() function to compare plain password and hashed password.
if (Hash::check('plain-text', $hashedPassword)) {
// The passwords match...
}
I found a solution, by using a library which helped me integrate the plugin on my website.
On top of that I had to do some minor configurations in the config file of the plugin. Changing the encryption method, so it matches the one in my Laravel application (BCrypt).
Later on I found out that I don't need to decrypt the password but just compare the hashes.
i want a authentication ,many people to login with a particular username and password at the same time and it is not good , where User A logs in with username = sammy and password = sammy123, User B cannot login with the same username = sammy and in one session password = sammy123 while I am still logged into an application...,i am using ruby 1.8.7 and devise gem for authentication, rails 2
1.add a column(flag) in table mdl_user store a 'false' value when user create new account .
2.Make a function which accept three value table name,flag field and username(which user enter) .this function return the value of flag field (true or false) .This function call if the user exist in database.
2.1 if 'false' returned then allow to login user and insert value into flag field 'true'.
2.2 if 'true'retuned then do not allow to login and print the message below the username and password field "This user already logged".Do not insert any value in database.
2.3 Now when sign out user then insert into flag field value 'flase'.
3.User allow to login only when flag field value 'false'.
better use this link http://www.gotealeaf.com/blog/how-to-use-devise-in-rails-for-authentication and check the version of devise gem you had used in your application.