PHP code example of patrikjak / auth

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

    

patrikjak / auth example snippets


use Patrikjak\Auth\AuthServiceProvider;
use Patrikjak\Utils\UtilsServiceProvider;

return [
    // ...
    UtilsServiceProvider::class,
    AuthServiceProvider::class,
];

// config/pjauth.php
'repositories' => [
    'user' => \App\Repositories\UserRepository::class,
],

'redirect_after_login'  => env('REDIRECT_AFTER_LOGIN', '/dashboard'),
'redirect_after_logout' => env('REDIRECT_AFTER_LOGOUT', '/'),

'features' => [
    'register'                => true,
    'login'                   => true,
    'password_reset'          => true,
    'change_password'         => true,
    'register_via_invitation' => false,
],

use Patrikjak\Auth\Http\Middlewares\VerifyRole;

Route::middleware(['web', 'auth', VerifyRole::withRole('admin')]);

'google' => [
    'client_id'     => env('GOOGLE_CLIENT_ID'),
    'client_secret' => env('GOOGLE_CLIENT_SECRET'),
    'redirect'      => sprintf('%s/auth/google/callback', env('APP_URL')),
],

'features' => [
    'register_via_invitation' => true,
],

'features' => [
    'change_password' => true,
],

'recaptcha' => [
    'enabled' => false,
],
bash
php artisan install:pjauth
bash
php artisan vendor:publish --tag="pjauth-assets" --force
php artisan vendor:publish --tag="pjauth-config"
php artisan vendor:publish --tag="pjauth-migrations" --force
php artisan vendor:publish --tag="pjauth-translations" --force
php artisan vendor:publish --tag="pjauth-views" --force   # optional
json
"scripts": {
    "post-update-cmd": [
        "@php artisan vendor:publish --tag=pjauth-config --force"
    ]
}
bash
php artisan pjauth:sync-roles
bash
php artisan pjauth:create-users
bash
php artisan pjauth:send-invite [email protected]
# or pass a role ID directly:
php artisan pjauth:send-invite [email protected] --role=<role-id>