This is a wrapper plugin for Overtrue/Socialite
- Install [ composer require 'overtrue/socialite' -vvv ] in your __includes directory
- and SweetAlert for Notification
- Login with ether facebook, github, google, linkedin, outlook, weibo, qq, wechat, and douban.
Clone Plugin Repository and Add it to Plugins Folder of your project or shared plugins folder. This will allows you to use the plugin in your Project.
Register to get client_id
and client_secret
keys and add them to you config in exSocialite $config
class exSocialite{
private static $config = [
'google' => [
'client_id' => '*****',
'client_secret' => '*****',
],
...
and in your login page, use Form1::callControllerAndBypassToken(token(), "exSocialite@processLogin(facebook)")
in your link. Example
Login with either
Facebook <a href="{{ Form1::callControllerAndBypassToken(token(), "exSocialite::processLogin(facebook)") }}"> Login with Facebook</a>
Google <a href="{{ Form1::callControllerAndBypassToken(token(), "exSocialite::processLogin(google)") }}"> Login with Google</a>
Github <a href="{{ Form1::callControllerAndBypassToken(token(), "exSocialite::processLogin(github)") }}"> Login with Github</a>
linkedin <a href="{{ Form1::callControllerAndBypassToken(token(), "exSocialite::processLogin(linkedin)") }}"> Login with linkedin</a>
outlook <a href="{{ Form1::callControllerAndBypassToken(token(), "exSocialite::processLogin(outlook)") }}"> Login with outlook</a>
weibo <a href="{{ Form1::callControllerAndBypassToken(token(), "exSocialite::processLogin(weibo)") }}"> Login with weibo</a>
qq <a href="{{ Form1::callControllerAndBypassToken(token(), "exSocialite::processLogin(qq)") }}"> Login with qq</a>
wechat <a href="{{ Form1::callControllerAndBypassToken(token(), "exSocialite::processLogin(wechat)") }}"> Login with wechat</a>
douban <a href="{{ Form1::callControllerAndBypassToken(token(), "exSocialite::processLogin(douban)") }}"> Login with douban</a>
Note: Remember to add redirection link during OAUTH registration Redirect Callback will hold the user info result, and it's will be called automatically. Should you need the full link. https://your-site-url.com/form/exSocialite::processCallback(facebook)
// redirect result is sent to
private static function registerUser($user){
dd($user);
}
$user->getId();
$user->getNickname();
$user->getName();
$user->getEmail();
$user->getAvatar();
$user->getOriginal();
$user->getToken();// or $user->getAccessToken()
$user->getProviderName(); // GitHub/Google/Facebook...
User model must consist of the following fields. Otherwise, change accordingly in exSocialite
wrapper to suit your needs
class User extends Model1{
// important, for storing new data and signing user in
...
public $user_name = '';
public $full_name = '';
public $email = '';
public $avatar = '';
public $registered_via = '';
public $password = '';
...
//Optional, based on your requirement. i.e add facebook_user_id if you using facebook.
public $registered_via = null;
public $facebook_user_id = '';
public $github_user_id = '';
public $google_user_id = '';
public $linkedin_user_id = '';
public $outlook_user_id = '';
public $weibo_user_id = '';
public $qq_user_id = '';
public $wechat_user_id = '';
public $douban_user_id = '';
...
please ensure you are not putting quote around your parameter.
exSocialite::processCallback(facebook)
instead of exSocialite::processCallback("facebook")
😗 from the creator of Easytax. Samson Iyanu (@samtax01)
- 微博 - OAuth 2.0 授权机制说明
- QQ - OAuth 2.0 登录QQ
- 微信公众平台 - OAuth文档
- 微信开放平台 - 网站应用微信登录开发指南
- 微信开放平台 - 代公众号发起网页授权
- 豆瓣 - OAuth 2.0 授权机制说明
MIT