Good Day,
I'm new and still learning in the Laravel 7 Framework. Is there a method on how I can use plain text password for my login page because on my existing database users password is only used plain text?
Good Day,
I'm new and still learning in the Laravel 7 Framework. Is there a method on how I can use plain text password for my login page because on my existing database users password is only used plain text?
You can manually retrieve a user then pass it to the Auth::login( $user ). Example:
$user = User::where( 'email' => $request->input( 'email' ) )
->where( 'password' => $request->input( 'password' ) )
->first();
if( $user ) {
Auth::login( $user );
}
If you are using Passport, this can be done by extending Laravel\Passport\Bridge\UserRepository
class.
use Laravel\Passport\Bridge\UserRepository;
use Laravel\Passport\Bridge\User;
class MyUserRepository extends UserRepository
{
public function getUserEntityByUserCredentials(
$username,
$password,
$grantType,
ClientEntityInterface $clientEntity
) {
$user = UserModel::first(['username' => $username]);
if ($user->password == $password) {
return new User($user->getAuthIdentifier());
}
return null;
}
}
Then you may want to bootstrap the repository to Passport via a service provider, ways to do it will depend on your authentication policy.