dev-master
9999999-dev
The Requires
- illuminate/contracts 5.1.*
- illuminate/support 5.1.*
- illuminate/session 5.1.*
- illuminate/console 5.1.*
The Development Requires
Wallogit.com
2017 © Pedro Peláez
Add this to your composer.json file, (*1)
Append this to your list of service providers in config/app.php, (*2)
'Morrelinko\SocialPlus\SocialPlusServiceProvider'
Run the command below, (*3)
$ php artisan vendor:publish --provider="Morrelinko\SocialPlus\SocialPlusServiceProvider"
[TODO - Extract from socialite], (*4)
Add provider configuration in config/services.php, (*5)
"facebook": {
"client_id": "...",
"client_secret": "..."
}
Handlers are a way SocialPlus delegates performing custom behaviours in your application, (*6)
during pre-authorization (authorize request) and post-authorization (callback request)., (*7)
This is where you may implement your login workflow and whatever., (*8)
Handlers are registered in config/socialplus.php like so, (*9)
<?php
return [
'authorize_handlers' => [
'login' => App\Handlers\SocialPlus\LoginHandler::class
]
];
Suggestion: Handlers should be placed in app/Handlers/SocialPlus folder, (*10)
namespace App\Handlers\SocialPlus;
use Morrelinko\SocialPlus\AuthorizeHandler;
use Laravel\Socialite\Contracts\User as SocialiteUser;
class LoginHandler implements AuthorizeHandler
{
public function authorize($provider)
{
// Called before any request is made to the provider
}
public function callback(SocialiteUser $socialiteUser, $accessToken, $provider)
{
// Executed after a successful authorization
}
public function exception($exception, $provider)
{
// Executed when an exception occurs / authorization fails
}
}
Once you done registering the handler, you create a link like so;, (*11)
// - route('socialplus.authorize', ['provider' => 'facebook', 'a' => 'login'])
// - Like So:
<a href="{{ route('socialplus.authorize', ['provider' => 'facebook', 'a' => 'login']) }}">Login With Facebook</a>
notice the 'a' parameter? .... That's the value you use to connect handler we just created and, (*12)
its what tells socialplus what handler to use for that specific action., (*13)
[WIP] This documentation is a work in progress and would really appreciate contributions. :), (*14)