PHP code example of salexcarvalho / govbr-auth

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

    

salexcarvalho / govbr-auth example snippets


Route::middleware('govbr.auth')->group(function () {
    Route::get('/dashboard', DashboardController::class);
});

// migration
$table->string('govbr_sub')->unique()->nullable();

// Model
protected $fillable = ['name', 'email', 'govbr_sub'];

use Salexcarvalho\GovBrAuth\Exceptions\GovBrAuthException;

public function register(): void
{
    $this->renderable(function (GovBrAuthException $e) {
        return redirect()->route('login')
            ->withErrors(['govbr' => 'Não foi possível autenticar via Gov.br. Tente novamente.']);
    });
}
bash
php artisan vendor:publish --tag=govbr-config