samedi 31 octobre 2015

Laravel 5 Social Authentification (keep session alive)

I am currently developing a web application with Laravel 5.0 and I authenticate my users with Facebook and Twitter using the socialite plugin.

Everything is working well now, I actually already made a post about it when I was struggling with it when I started. So if you want to see the code I'm running you can refer to my previous article.

But now I would like to keep those sessions "alive"? , I don't want to click on the login button everyday and I am having a hard time finding information about it...

The thing is I am not even sure if I look at the right place.. because I am a real newbie in this area and I don't know If I should read more about the Facebook and Twitter SDK or should I look on the Laravel side only ?

I've must have read the Laravel authentication chapter a hundred times but I really don't know where to start. Remembering a token sounds like the way to go but I have no idea whatsoever how to implement it in my current environment. This is the method provided by Laravel:

if (Auth::attempt(['email' => $email, 'password' => $password], $remember))
{
 // The user is being remembered...
}

But when we use the socialite plugin we have to log in the user with the Auth::loginUsingId(id); method, am I wrong ? So how can we remember the user with this method ? Is it possible ? Is it the way to go ?

I hope my problem is clear enough. So if anyone could tell me where should I focus my researches that would be great !



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire