chazzuka/authron

multi tenant auth manager for laravel

dev-develop 2014-12-02 08:35 UTC

This package is not auto-updated.

Last update: 2024-12-17 04:06:41 UTC


README

add multi tenant auth configuration at config/auth.php

    'resolver' => [
    	'default' => 'member',
        'member' => [
            'driver' => 'eloquent',
            'model' => 'App\Account\Member',
        ],
        'audience' => [
            'driver' => 'audience',
            'model' => 'App\Audiences\Audience',
        ],
    ],

Replace laravel auth provider in config/app.php with Chazzuka\Authron\AuthronServiceProvider

// login with default auth manager
Auth::attempt($crendetials); 
Auth::guest();
Auth::check();

// above is equivalent to
Auth::member()->attempt($credentials);
Auth::member()->guest();
Auth::member()->check();

// login audience
Auth::audience()->attempt($credentials);
Auth::audience()->guest();
Auth::audience()->check();

Register custom user provider

// Register only for audience auth manager
$this->app['auth']->audience()->extend('audience', function ()
{
    $provider = new AudienceProvider($this->app['audiences']);

    return new Guard('audience', $provider, $this->app['session.store']);
});

// register for all registered managers
$this->app['auth']->extend('audience', function ()
{
    $provider = new AudienceProvider($this->app['audiences']);

    return new Guard('audience', $provider, $this->app['session.store']);
});