Skip to content

Riyazkhan1989/laravel-social-email-authentication

 
 

Repository files navigation

Laravel Social and Email Authentication

This project is related to tutorial from Codingo Tuts.

In tutorial I am creating Laravel application with email authentication and user roles, but I am also using [Laravel Socialite] for Facebook and Twitter logins. At the end of this tutorial you will be able to use any other social provider in matter of seconds.

What is covered

Everything is covered there so new Laravel developers can grasp it quickly. I am following simple plan while I am developing:

This plan is not strict and if you are familiar with something you may just skip that part.

Implementing new Social Providers in under 20 seconds

Main beauty is modular approach in implementing new Socialite providers. Application uses to routes one for redirecting user to certain social site and other to accept response from that site:

s = 'social.';
Route::get('/social/redirect/{provider}',   ['as' => $s . 'redirect',   'uses' => 'Auth\AuthController@getSocialRedirect']);
Route::get('/social/handle/{provider}',     ['as' => $s . 'handle',     'uses' => 'Auth\AuthController@getSocialHandle']);

To add new social provider you just need to insert new element in services.php like this:

    'facebook' => [
        'client_id'     => env('FB_ID'),
        'client_secret' => env('FB_SECRET'),
        'redirect'      => env('FB_REDIRECT')
    ],

    'twitter' => [
        'client_id'     => env('TW_ID'),
        'client_secret' => env('TW_SECRET'),
        'redirect'      => env('TW_REDIRECT')
    ],

And now you need to create new login link using following route:

route('social.redirect', ['provider' => 'provider_key_from_services']); //example
route('social.redirect', ['provider' => 'facebook']);
route('social.redirect', ['provider' => 'twitter']);

###Todo's Project is not over, I will publish few more tutorials regarding this matter. You can expect:

  • Handling when user disallows social app access
  • Taking emails of users who sign-up over Twitter and other providers which don't share that data
  • User account actions, like change password, change email etc

About

Laravel Social and Email Authentication. Login system with email registration and Facebook & Twitter social logins using Laravel Socialite.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 98.3%
  • JavaScript 1.2%
  • Other 0.5%