Skip to content

ehexphp/ex_socialite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

exSocialite (v1.0)

This is a wrapper plugin for Overtrue/Socialite

Requirement

  • Install [ composer require 'overtrue/socialite' -vvv ] in your __includes directory
  • and SweetAlert for Notification

Features

  • Login with ether facebook, github, google, linkedin, outlook, weibo, qq, wechat, and douban.

Quick Use

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.

Usage

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>

Redirect Callback

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);
    }

Verbose result from registerUser($user){ }

    
    $user->getId();
    $user->getNickname();
    $user->getName();
    $user->getEmail();
    $user->getAvatar();
    $user->getOriginal();
    $user->getToken();// or $user->getAccessToken()
    $user->getProviderName(); // GitHub/Google/Facebook...
    

Requirement in User Model

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 = '';
        ...
        

Likely Error

please ensure you are not putting quote around your parameter. exSocialite::processCallback(facebook) instead of exSocialite::processCallback("facebook")

Author

😗 from the creator of Easytax. Samson Iyanu (@samtax01)

Contributor [ Socialite Creator ]

Reference





License

MIT

About

Socialite wrapper for Social media OAUTH2 login

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages