1. Go to this page and download the library: Download basecodeoy/laravel-passage 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/ */
basecodeoy / laravel-passage example snippets
declare(strict_types=1);
use App\Models\User;
use BaseCodeOy\Passage\Facades\Passage;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/
Route::post('/passage/login', function (Request $request): void {
Passage::authentication()->magicLink()->login($request->get('email'));
$request->session()->flash('status', 'We have e-mailed your magic link!');
return redirect()->back();
});
Route::post('/passage/register', function (Request $request): void {
Passage::authentication()->magicLink()->register($request->get('email'));
User::create(['email' => $request->get('email')]);
$request->session()->flash('status', 'We have e-mailed your magic link!');
return redirect()->back();
});
Route::get('/passage/{YOUR_APP_ID}', function (Request $request) {
$response = Passage::authentication()->magicLink()->activate($request->query('psg_magic_link'));
$currentUser = Passage::authentication()->authenticatedUsers($response['auth_token'])->currentUser();
Auth::login(User::where('email', $currentUser['email'])->firstOrFail());
$request->session()->flash('status', 'You have been logged in!');
return redirect($response['redirect_url']);
});
Route::get('/passage/{YOUR_APP_ID}/dashboard', function (Request $request): void {
return view('dashboard');
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.