PHP code example of raditzfarhan / laravel-user-security

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

    

raditzfarhan / laravel-user-security example snippets


'providers' => [
    ...
    RaditzFarhan\UserSecurity\UserSecurityServiceProvider::class,
    ...
],

...
$app->register(RaditzFarhan\UserSecurity\UserSecurityServiceProvider::class);
...

..
$app->withFacades(true, [
    ...
    RaditzFarhan\UserSecurity\Facades\RFAuthenticator::class => 'RFAuthenticator'
]);
...



namespace App;

...
use RaditzFarhan\UserSecurity\Traits\UserSecurable;

class User extends Model implements AuthenticatableContract, AuthorizableContract
{
    ...
    use UserSecurable;
    ...
}

// to add/update security pin for eloquent user
$user->updateSecurityPin($security_pin);

// to add/update entropy for eloquent user
$user->updateEntropy($entropy);

// to add/update multiple authenticators
$user->updateMultipleAuthenticators(['security_pin' => $security_pin, 'mnemonic_entropy' => $entropy]);

// Success response

// using service container to generate mnemonic object
$mnemonic = app('RFAuthenticator')->mnemonic()->generate();

// using alias to generate mnemonic object
$mnemonic = \RFAuthenticator::mnemonic()->generate();

// Use mnemonic codes to find entropy
$mnemonic = \RFAuthenticator::mnemonic()->words($words);

// Generate Mnemonic using specified Entropy
$mnemonic = \RFAuthenticator::mnemonic()->entropy($entropy);