PHP code example of bijon / laravel-auth

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

    

bijon / laravel-auth example snippets


use Bijon\LaravelAuth\Facades\GoogleOAuth;

Route::get('/auth/google/redirect', fn () => GoogleOAuth::redirect());

Route::get('/auth/google/callback', function () {
    GoogleOAuth::callback(); // validates state, exchanges code, fires GoogleLoginSucceeded

    return redirect()->intended('/dashboard');
});

use Bijon\LaravelAuth\Events\GoogleLoginSucceeded;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;

Event::listen(GoogleLoginSucceeded::class, function (GoogleLoginSucceeded $event) {
    $user = User::firstOrCreate(
        ['email' => $event->user->email],
        ['name' => $event->user->name ?? 'Google User', 'password' => Str::password(32)],
    );

    Auth::login($user, remember: true);
});

Route::post('/login', LoginController::class)->middleware('captcha');

$request->validate([
    'cf-turnstile-response' => ['

use Bijon\LaravelAuth\Facades\Captcha;

$result = Captcha::verify($token, $request->ip());

if ($result->failed()) {
    // $result->errorCodes, $result->score (reCAPTCHA), $result->provider
}
bash
php artisan vendor:publish --tag=laravel-auth-config