How to check password without using Auth in Laravel

How to check password without using Auth in LaravelHarshit VaidBlockedUnblockFollowFollowingMay 28Hello Guys!I am here with another interesting blog about Laravel.

Many Users uses the Auth Package to authenticate users.

Auth package consists of all the basic functionality like Login, Register and Forgets Password to uses But in some situations, we need to authenticate the user's password without using auth package.

So in this story, I will discuss how we can authenticate the users without the help of auth.

One more thing if you are beginners then I will tell you that the Laravel uses the hash generated passwords for the users for securities reasons.

Let’s start the story :I assumed that you have created the user's table and created the user’s model.

Create a function in the controller file like below code:public function checkUserPassword(Request $request){ $userPwd = $request->managerpwd; $userName = $request->manageruser; $user = User::where('id', $userName)->first(); $passwordCheck = Hash::check($userPwd, $user->password); if($passwordCheck){ $output = ['success' => 1, 'msg' => 'Details matched successfully' ]; }else{ $output = [ 'success' => 0, 'msg' => 'Something went wrong.

Details not matched' ]; } return $output; }Here we have used Hash::check method for authenticating the userThis method will return true or false in the response.

I hope the above article will help you to solve the users.

Happy Coding :).. More details

Leave a Reply