2017 © Pedro Peláez
 

library verify

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

image

toddish/verify

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

  • Tuesday, July 7, 2015
  • by Toddish
  • Repository
  • 21 Watchers
  • 179 Stars
  • 18,922 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 48 Forks
  • 6 Open issues
  • 25 Versions
  • 3 % Grown

The README.md

Verify - Laravel 5 Auth Package


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

For Laravel 5.0, use Verify 4.*.
For Laravel 4.2, use Verify 3.*.
For Laravel < 4.2, use Verify 2.*., (*2)


  • Secure password storage with salt
  • Role/permission based authentication
  • Exceptions for intelligent handling of errors
  • Configurable/extendable
  • Licensed under the MIT license

Installation

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

"require": {
    "toddish/verify": "~5"
}

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

composer update

Registering the Package

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

'providers' => [
    'Toddish\Verify\Providers\VerifyServiceProvider
],

Change the driver

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

'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()., (*7)

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

use Toddish\Verify\Models\User as VerifyUser;

class User extends VerifyUser
{
    // Code
}

Publish the assets

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

php artisan vendor:publish

Or, if you want to publish parts of Verify individually:, (*10)

php artisan vendor:publish --provider="Toddish\Verify\Providers\VerifyServiceProvider" --tag="config"

The available tags are config, migrations and seeds., (*11)

Migration

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

php artisan migrate
php artisan db:seed

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

Usage

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

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

etc., (*15)

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

The relationships are as follows:, (*17)

  • 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:, (*18)

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

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

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([$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

Auth::verify()

Verify ships with a new login method, Auth::verify()., (*20)

This method takes the same arguments as Auth::attempt(), with the main difference being it returns a string, and checks if the user is disabled or verified too., (*21)

use Toddish\Verify\Helpers\Verify;

switch (Auth::verify($credentials))
{
  case Verify::SUCCESS:
    // Successful log in
    break;
  case Verify::INVALID_CREDENTIALS:
  case Verify::UNVERIFIED:
  case Verify::DISABLED:
    // Error!
    break;
}

Documentation

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

The Versions

07/07 2015

dev-master

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

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

  Sources   Download

MIT

The Requires

 

laravel auth roles permissions verify

07/07 2015

v5.0.0

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

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

  Sources   Download

MIT

The Requires

 

laravel auth roles permissions verify

07/07 2015

dev-develop

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

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

  Sources   Download

MIT

The Requires

 

laravel auth roles permissions verify

05/07 2015

v4.0.1

4.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

12/04 2015

dev-feature/L5

dev-feature/L5 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/09 2014

v3.1.0

3.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

  • php >=5.4.0

 

laravel auth roles permissions verify

17/06 2014

v3.0.1

3.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

  • php >=5.4.0

 

laravel auth roles permissions verify

15/06 2014

v3.0.0

3.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

  • php >=5.4.0

 

laravel auth roles permissions verify

10/05 2014

v2.4.1

2.4.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

  • php >=5.3.0

 

laravel auth roles permissions verify

21/04 2014

v2.4.0

2.4.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

  • php >=5.3.0

 

laravel auth roles permissions verify

24/02 2014

v2.3.1

2.3.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

  • php >=5.3.0

 

laravel auth roles permissions verify

20/01 2014

v2.3.0

2.3.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

  • php >=5.3.0

 

laravel auth roles permissions verify

08/01 2014

v2.2.2

2.2.2.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

  • php >=5.3.0

 

laravel auth roles permissions verify

16/12 2013

v2.2.1

2.2.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

  • php >=5.3.0

 

laravel auth roles permissions verify

03/11 2013

v2.2.0

2.2.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

  • php >=5.3.0

 

laravel auth roles permissions verify

23/10 2013

v2.1.1

2.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

05/10 2013

v2.1.0

2.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

24/09 2013

2.0.2

2.0.2.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

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

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