PHP code example of devinci-it / shadow-auth

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

    

devinci-it / shadow-auth example snippets



declare(strict_types=1);

Config;
use DevinciIT\ShadowAuth\Facade\Auth;

Config::set([
    'storage_path' => __DIR__ . '/storage/shadow.php',
    'session_key' => 'shadow_auth_user',
    'totp_enabled' => true,
    'registration_constraints' => [
        'unique_fields' => ['username', 'email'],
        'case_insensitive_fields' => ['username', 'email'],
    ],
]);

Auth::boot();

$ok = Auth::registerWithData('alice', 'secure-password', [
    'email' => '[email protected]',
]);

$result = Auth::beginLogin('alice', 'secure-password');

if ($result === 'authenticated') {
    // Logged in
}

if ($result === 'totp_

Auth::

Config::set([
    'storage_path' => __DIR__ . '/storage/shadow.php',
    'totp_enabled' => true,
    'registration_constraints' => [
        'unique_fields' => ['username', 'email'],
        'case_insensitive_fields' => ['username', 'email'],
    ],
]);