2017 © Pedro Peláez
 

library verify

A simple authentication bundle for Laravel 4. It features roles, permissions, password salting and is fully extendable.

image

andheiberg/verify

A simple authentication bundle for Laravel 4. It features roles, permissions, password salting and is fully extendable.

  • Monday, June 2, 2014
  • by AndreasHeiberg
  • Repository
  • 1 Watchers
  • 0 Stars
  • 78 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 48 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

Verify - Laravel 4 Auth Package


A simple role/permission authentication package for Laravel 4, (*1)


  • Role/permission based authentication
  • Exceptions for intelligent handling of errors
  • Configurable/extendable

Installation

Add Verify to your composer.json file:, (*2)

"require": {
    "andheiberg/verify": "2.0.*"
}

Now, run a composer update on the command line from the root of your project:, (*3)

composer update

Registering the Package

Add the Verify Service Provider to your config in app/config/app.php:, (*4)

'providers' => array(
    'Toddish\Verify\VerifyServiceProvider'
),

Change the driver

Then change your Auth driver to 'verify' in app/config/auth.php:, (*5)

'driver' => 'verify',

You may also change the 'model' value to 'Toddish\Verify\Models\User' if you want to be able to load Verify's User model when using Auth::user()., (*6)

Alternatively, you can simply create your own User model, and extend Verify's:, (*7)

use Toddish\Verify\Models\User as VerifyUser;

class User extends VerifyUser
{
    // Code
}

Publish the config

Run this on the command line from the root of your project:, (*8)

php artisan config:publish toddish/verify

This will publish Verify's config to app/config/packages/toddish/verify/., (*9)

Migration

Now migrate the database tables for Verify. Run this on the command line from the root of your project:, (*10)

php artisan migrate --package="toddish/verify"

You should now have all the tables imported, complete with a sample user, called admin, with a password of password., (*11)

Usage

The package is intentionally lightweight. You add Users, Roles and Permissions like any other Model., (*12)

$user = new Toddish\Verify\Models\User;
$role = new Toddish\Verify\Models\Role;
$permission = new Toddish\Verify\Models\Permission;

etc., (*13)

All models are in the namespace 'Toddish\Verify\Models\'., (*14)

The relationships are as follows:, (*15)

  • Roles have many and belong to Users
  • Users have many and belong to Roles
  • Roles have many and belong to Permissions
  • Permissions have many and belong to Roles

Relationships are handled via the Eloquent ORM, too:, (*16)

$role->permissions()->sync(array($permission->id, $permission2->id));

More information on relationships can be found in the Laravel 4 Eloquent docs., (*17)

Basic Examples

// Create a new Permission
$permission = new Toddish\Verify\Models\Permission;
$permission->name = 'delete_user';
$permission->save();

// Create a new Role
$role = new Toddish\Verify\Models\Role;
$role->name = 'Moderator';
$role->level = 7;
$role->save();

// Assign the Permission to the Role
$role->permissions()->sync(array($permission->id));

// Create a new User
$user = new Toddish\Verify\Models\User;
$user->username = 'Todd';
$user->email = 'todd@toddish.co.uk';
$user->password = 'password'; // This is automatically salted and encrypted
$user->save();

// Assign the Role to the User
$user->roles()->sync(array($role->id));

// Using the public methods available on the User object
var_dump($user->is('Moderator')); // true
var_dump($user->is('Admin')); // false

var_dump($user->can('delete_user')); // true
var_dump($user->can('add_user')); // false

var_dump($user->level(7)); // true
var_dump($user->level(5, '<=')); // false

Documentation

For full documentation, have a look at http://docs.toddish.co.uk/verify-l4., (*18)

The Versions

02/06 2014

dev-master

9999999-dev http://docs.toddish.co.uk/verify-l4/

A simple authentication bundle for Laravel 4. It features roles, permissions, password salting and is fully extendable.

  Sources   Download

MIT

The Requires

 

laravel auth roles permissions verify

11/05 2013

v2.0.1

2.0.1.0 http://docs.toddish.co.uk/verify-l4/

A simple authentication bundle for Laravel 4. It features roles, permissions, password salting and is fully extendable.

  Sources   Download

MIT

The Requires

 

laravel auth roles permissions verify

11/05 2013

dev-develop

dev-develop http://docs.toddish.co.uk/verify-l4/

A simple authentication bundle for Laravel 4. It features roles, permissions, password salting and is fully extendable.

  Sources   Download

MIT

The Requires

 

laravel auth roles permissions verify

11/05 2013

v2.0.0

2.0.0.0 http://docs.toddish.co.uk/verify-l4/

A simple authentication bundle for Laravel 4. It features roles, permissions, password salting and is fully extendable.

  Sources   Download

MIT

The Requires

 

laravel auth roles permissions verify

14/04 2013

v1.1.1

1.1.1.0 http://docs.toddish.co.uk/verify-l4/

A simple authentication bundle for Laravel 4. It features roles, permissions, password salting and is fully extendable.

  Sources   Download

MIT

The Requires

 

laravel auth roles permissions verify

01/04 2013

v1.1.0

1.1.0.0 http://docs.toddish.co.uk/verify-l4/

A simple authentication bundle for Laravel 4. It features roles, permissions, password salting and is fully extendable.

  Sources   Download

MIT

The Requires

 

laravel auth roles permissions verify

23/03 2013

1.0.0

1.0.0.0 http://docs.toddish.co.uk/verify-l4/

A simple authentication bundle for Laravel 4. It features roles, permissions, password salting and is fully extendable.

  Sources   Download

MIT

The Requires

 

laravel auth roles permissions verify

19/03 2013

v1.0.0-beta

1.0.0.0-beta http://docs.toddish.co.uk/verify-l4/

A simple authentication bundle for Laravel 4. It features roles, permissions, password salting and is fully extendable.

  Sources   Download

MIT

The Requires

 

laravel auth roles permissions verify

19/03 2013

v1.0.0-alpha

1.0.0.0-alpha http://docs.toddish.co.uk/verify-l4/

A simple authentication bundle for Laravel 4. It features roles, permissions, password salting and is fully extendable.

  Sources   Download

MIT

The Requires

 

laravel auth roles permissions verify