PHP code example of codebot / laravel-usub

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

    

codebot / laravel-usub example snippets


    public function handle( $request, Closure $next )
    {
        if ( !$request->user()->hasRole( 'admin' ) )
        {
            abort( 401 );
        }

        return $next( $request );
    }

@if( \Auth::user()->hasRole('admin') )
    @_sign_in' => route('home'),
        'on_sign_out' => route('backend.user.index')
    ])
@endif

@if( \Illuminate\Support\Facades\Cookie::get('usub_token') )
    <li class="nav-item">
        <form action="{{ route('usub.sign_out') }}" method="post">
            @csrf
            <button type="submit" class="btn btn-primary">Back to Admin</button>
        </form>
    </li>
@endif

USUB_TOKEN_EXPIRATION=120
USUB_TOKEN_LENGTH=100
USUB_REDIRECT_TO_ON_SIGN_IN="/"
USUB_REDIRECT_TO_ON_SIGN_OUT="/"
USUB_REDIRECT_TO_ON_COOKIE_EXPIRATION="/"