首页 > 解决方案 > Disable auto hashing of password while login - Laravel

问题描述

Is there anyway to change or disable the auto hashing password in laravel while login? According to their documentation,

The user will be retrieved by the value of the email column. If the user is found, the hashed password stored in the database will be compared with the password value passed to the method via the array. You should not hash the password specified as the password value, since the framework will automatically hash the value before comparing it to the hashed password in the database. If the two hashed passwords match an authenticated session will be started for the user.

Since it clearly says the framework will auto hash the password and we (developers) should not hash the password while login. What I want is to manually hash the password from the user input and then compare it with the stored hash password in DB. Any idea what changes I have to make in framework or where?

I am using below code to authenticate users. (I have two types of users Buyers and Sellers).

 (Auth::guard('buyer')->attempt(['buyerData_primaryemail' => $request->emailOrNumber, 
    'password' => $request->password], $request->get('remember')))

(Auth::guard('seller')->attempt(['sellerData_primaryemail' => $request->emailOrNumber, 
    'password' => $request->password], $request->get('remember')))

标签: phplaravelauthenticationhash

解决方案


推荐阅读