Okay, so to keep it simple I have a users
table, and a User
model. The table contains a unique identifier com_id
(plus other user info), which I'd like to login with, but no password.
I'd like to log the user in, and be able to access their data via the Auth driver: Auth::user()->email
etc, but I'm having some problems logging them in.
if (Auth::attempt(['com_id' => $com_id]))
{
dd("successful login");
}
With this, I get an error regarding the UserInterface
, so in my Model I add:
use Illuminate\Auth\UserInterface;
class User extends Eloquent implements UserInterface {
protected $table = 'users';
protected $guarded = array('id');
public function getAuthIdentifier()
{
return $this->steam_community_id;
}
public function getAuthPassword()
{
return $this->password;
}
}
But what do I do about the password? I can't remove the function since it's required, and I'm not sure what the getAuthIdentifier
is supposed to refer to?
Any help would be nice.
I could handle this through Sessions, but surely this is possible the "normal" way.
To log in user without a password in Laravel 4. You just need to call method login
.
Auth::login($user);
This method will log in your user without any credential check.
If you need to check the credentials in other hand, this method which will check the credentials.
Auth::attempt(array('email' => $email, 'password' => $password), true);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With