HamidOsouli
2 years ago
8056
7
Laravel

Using Auth::attempt() without password

Posted 2 years ago by HamidOsouli

@bobbybouwmann I want to build a login system without password. I searched a lot and found out that if we replace validateCredentials method with true in EloquentUserProvider, we could do that. But How can I do that without changing this file in vendor :( Should I make my own AuthProvider for that? here is the EloquentUserProvider class

<?php

namespace Illuminate\Auth;

use Illuminate\Support\Str;
use Illuminate\Contracts\Auth\UserProvider;
use Illuminate\Contracts\Hashing\Hasher as HasherContract;
use Illuminate\Contracts\Auth\Authenticatable as UserContract;

class EloquentUserProvider implements UserProvider
{
public function validateCredentials(UserContract $user, array $credentials)
    {
//It works great if we Change this block of method to true
        $plain = $credentials['password'];

        return $this->hasher->check($plain, $user->getAuthPassword());
    }

Please sign in or create an account to participate in this conversation.