PHP code example of boldogteam / login

1. Go to this page and download the library: Download boldogteam/login 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/ */

    

boldogteam / login example snippets


// app/Providers/AppServiceProvider.php
use Illuminate\Support\Facades\Cache;
// ...
    public function register()
    {
        // ...
        $this->app->bind(
            '\Auth0\SDK\Helpers\Cache\CacheHandler',
            function() {
                static $cacheWrapper = null;
                if ($cacheWrapper === null) {
                $cache = Cache::store();
                $cacheWrapper = new LaravelCacheWrapper($cache);
            }
            return $cacheWrapper;
        });
    }

// config/laravel-auth0.php
// ...

/*
|--------------------------------------------------------------------------
|   Auth0 Organizations
|--------------------------------------------------------------------------
|   organization (string) Optional. Id of an Organization, if being used. Used when generating log in urls and validating token claims.
*/

'organization' => 'org_E6WbrPMQU2UJn6Rz',

// Expects the Laravel plugin to be configured first, as demonstrated above.

App::make('auth0')->login();

// routes/example.php

Route::get('/invite', [ExampleIndexController::class, 'invite'])->name('invite');

// Http/Controllers/Example/ExampleIndexController.php



namespace App\Http\Controllers\Auth;

use Illuminate\Support\Facades\App;
use App\Http\Controllers\Controller;

class ExampleIndexController extends Controller
{
  /**
   * Redirect to Auth0 Universal Login using the invitation code
   *
   * @return void
   */
  public function invite()
  {
      App::make('auth0')->handleInvitation();
  }


// get user
auth('auth0')->user();
// check if logged in
auth('auth0')->check();
// protect routes via middleware use
Route::group(['middleware' => 'auth:auth0'], function () {});