Change the Hash password in laravel using Phpmyadmin - php

I use Hash::make($req->pass); to login in Laravel. Now I forgot the password. Can I change the password by editing PHPMyAdmin? Is there any PHPMyadmin function to change the Bcrypt?
For eg. To change the password stored in MD5, I can change it by using MD5 function. And it works fine for all WordPress logins.
Thanks in Advance

I would use Tinker to achieve this:
php artisan tinker
$user = App/Models/User()::find(/* user_id */);
$user->password = Hash::make('your new password here');
$user->save();
// You should receive a "true" if the update is successful.
// This can all be done via the command line.
You can also (for the sake of answering your question) just output the password from the route file:
Route::get('generate-password', function () {
return Hash::make('your new password');
})
visit the '/generate-password' url, copy that password, then paste it into PHPMyAdmin

One way to change the password manually is to get the value from
$pw=Hash::make('yourpassword');
to a variable and copy that value into users table password field.

Related

Laravel 5.4 - Get user data without log-in (for API)

I want to get user data
I tried using
$user_data = App\User::where(["username"=>"admin", "password"=>bcrypt("test123")])->get();
But it is not working! I am sure the username and password is correct!
then I tried another one without bcrypt
$user_data = App\User::where(["username"=>"admin", "password"=>"test123"])->get();
And still not working!.
I don't know what is the problem.
I wondering if I can use Auth::attempt just to get the user data (without log-in)
$user_data = Auth::attempt(["username"=>"admin", "password"=>"test123"]);
Auth::attempt will signing you in. But I don't want that. I just want to get the user data only (without sign-in)
I forgot to mention that I'm creating an API...
However, I solved the problem by using Auth::once()
Auth::once(['username'=>'admin', 'password'=>'test123']);

Laravel custom Authenication with different fields

I have a table in my database called (users_system) contains:
user_id
user_pass (plain text)
... some other fields
What I want is to be able to do laravel(5.2) authentication using those two fields considering the (Auth::attempt) only deal with email and hashed password.
So is that possible and if so how to do it?
You can check credentials and login user manually:
$userSystem = UserSystem::where('user_id', $userId)->where('user_pass', $password)->first();
if (!is_null($userSystem)) {
// Manually login user.
$user = User::find($userId);
Auth::login($user);
}
But this is a terrible idea to use plain text passwords. You should never do that in a real app.

Aauth - update_user() - Not sure how to use

Perhaps I'm just unsure on the documentation. I've tried to figure it out, but I've never used this Codeigniter library before (Aauth). I'm attempting to create a form / page that will allow a user to change their password. The form works fine, but it's not changing the users password in the database.
The documentation says this:
Please note that I am not sure what "FALSE" represents. I do not see a change password method in the documentation provided here.
update_user($user_id, $email = FALSE, $pass = FALSE, $name = FALSE)
Updates user by using user_id
I'm not seeing any errors.
I'm writing something like this:
// get user info for currently logged user (this part works)
$userdata = $this->aauth->get_user();
// Change Password (not currently changing the password for the user)
$this->aauth->update_user($userdata->id, $userdata->email, $_POST['formpassword']);
Whoops, didn't realize when it said "FALSE" it meant it was required.
The correct solution:
// I did not want to change email or name. Password only.
$this->aauth->update_user($userdata->id, FALSE, $_POST['formpassword'], FALSE);

laravel 5 Hash::check not working

I want to check whether old password which user typed is matched with DB password using check hash, but its not working correctly please advice.
Below is my code which I used to update password function
fields which required are old_passwrord, new_password.
Currently it doesn't go to hash check fucntion and directly update password.
else if (Hash::check('password', $getPassword->password))
{
return ['error'=>['code'=>206, 'message'=>'old password is not matching']];
}
Replace
else if (Hash::check('password', $getPassword->password))
with
else if ( ! Hash::check('password', $getPassword->password))

How to change my database information in livecart after change database password?

My livecart can't access after change the database password, but find the database config file , and found the message like this:
return
'mysql://guaguaco_lcdb:.#RR?HbQ+CBQ#localhost/guaguaco_livecartdb';
What can I do to change the password?
Thanks.
The password is inbetween the first : and the last #
mysql://guaguaco_lcdb:.#RR?HbQ+CBQ#localhost/guaguaco_livecartdb
Change to this
mysql://guaguaco_lcdb:NEWPASSWORD#localhost/guaguaco_livecartdb
where NEWPASSWORD is your new password

Categories