PHP code example of framgia-education / laravel-omniauth-hrsystem

1. Go to this page and download the library: Download framgia-education/laravel-omniauth-hrsystem library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

framgia-education / laravel-omniauth-hrsystem example snippets


'providers' => [
    // Other service providers...

    Framgia\Education\Auth\FramgiaAuthServiceProvider::class,
],

'aliases' => [
    // Other aliases

    'FAuth' => Framgia\Education\Auth\Facades\FramgiaAuth::class,
],

'framgia' => [
    'client_id' => 'your-framgia-auth-app-id',
    'client_secret' => 'your-framgia-auth-app-secret',
    'redirect' => 'http://your-callback-url',
],



namespace App\Http\Controllers\Auth;

use FAuth;

class LoginController extends Controller
{
    /**
     * Redirect the user to the GitHub authentication page.
     *
     * @return Response
     */
    public function redirectToFramgiaAuth()
    {
        return FAuth::redirect();
    }

    /**
     * Obtain the user information from GitHub.
     *
     * @return Response
     */
    public function handleFramgiaAuthCallback()
    {
        $user = FAuth::user();

        // $user->token;
    }
}

Route::get('login/framgia', 'Auth\LoginController@redirectToFramgiaAuth');
Route::get('login/framgia/callback', 'Auth\LoginController@handleFramgiaAuthCallback');

$user = FAuth::user();

$token = $user->token;
$refreshToken = $user->refreshToken; // not always provided
$expiresIn = $user->expiresIn;

// Example infomation:
$user->getId(); // Or maybe $user->id
$user->getName(); // Or maybe $user->name
$user->getEmail(); // Or maybe $user->email
$user->getAvatar(); // Or maybe $user->avatar
$user->getGender(); // Or maybe $user->gender
$user->getBirthday(); // Or maybe $user->birthday
$user->getPhoneNumber(); // Or maybe $user->phoneNumber

// All infomation about user will be stored here:
$user->getRaw(); // Or maybe $user->user

$user = FAuth::userFromToken($token);