PHP code example of tecnomanu / unilogin-laravel-lumen

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

    

tecnomanu / unilogin-laravel-lumen example snippets


$app->alias('view', Illuminate\View\Factory::class);

$app->alias('mailer', \Illuminate\Contracts\Mail\Mailer::class);
$app->alias('mail.manager', Illuminate\Mail\MailManager::class);
$app->alias('mail.manager', Illuminate\Contracts\Mail\Factory::class);
$app->alias('Notification', Illuminate\Support\Facades\Notification::class);

$app->configure('mail');
$app->configure('view');

Route::get('/login-success', function (Request $request) {     
    // Receive from request "email";

    // Your login logic here. 
    // ...
    // Or use this example
    $user = User::where('email', $request->email)->first();
    Auth::login($user);
    return redirect('/');

})->middleware('unilogin.success');

    // SuccessTokenMiddleware.php  //... 
    public function handle(Request $request, Closure $next) {     
        // ...     
        $credentials = $request->get('credentials');      
        
        // Merge additional fields to the request     
        
        $request->merge([
            'email' => $credentials['email'], 
            'company_id' => $credentials['company_id'] 
        // New field     
        ]);          
        return $next($request); 
    } 
    //...