PHP code example of gusmanwidodo / auth-kit

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

    

gusmanwidodo / auth-kit example snippets


use Gusmanwidodo\AuthKit\Contracts\AuthPlugin;

class HelloPlugin implements AuthPlugin
{
    public function id(): string { return 'hello'; }
    public function boot(): void {}
}

'plugins' => [
    App\Auth\HelloPlugin::class,
],

public function beforeHooks(): array
{
    return [
        'otp.verify' => function (HookContext $ctx) {
            if ($ctx->get('expires_at') < now()->timestamp) {
                $ctx->set('valid', false)->stop();
            }
        },
    ];
}

$ctx = app(AuthManager::class)->runBefore('otp.verify', [
    'expires_at' => $record->expires_at,
    'valid' => true,
]);

if ($ctx->get('valid') === false) { /* reject */ }
bash
php artisan vendor:publish --tag=auth-kit-config