Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

codenex's avatar

Authentication without password

I'm trying to implement a very simple authentication for my app but not sure how to override the custom authentication system. What should happen is the database is queried to see if the users machine is listed - If it is, the user should be logged in.

I tried using the Auth facade like I would normally use but it looks like it depends on a password.

public function login()
{
        $hostname = get_hostname();  // helper method to get hostname of machine

        if (Auth::attempt(['hostname' => $hostname])) {
            return redirect()->intended('home');
        }
}

The error is

ErrorException in EloquentUserProvider.php line 116:
Undefined index: password

Again there is not hashed passwords to compare which is normally the second value in the passed array. Is there a simple way to implement what I'm trying to do?

0 likes
4 replies
d3xt3r's avatar
d3xt3r
Best Answer
Level 29

If that is all you need, just check whether the such a user exists and login him in yourself


$hostname = get_hostname();

$user = findUserByHostame($hostname); // Something like User:: where() or whatever depending on your impl.

if($user)  {
    Auth::login($user);
    return redirect()->intended('home');

}
3 likes

Please or to participate in this conversation.