2017 © Pedro PelĂĄez
 

library accessable

image

milkwood/accessable

  • Monday, March 9, 2015
  • by Pab89
  • Repository
  • 1 Watchers
  • 0 Stars
  • 15 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

Accessable

Laravel middleware for authfication, (*1)

Step 1: Install Through Composer

Composer require 'milkwood/accessable'

Step 2: Add The ServiceProvider

Add the following lines to your service providers i Config/App.php and a CH facade You are here adding both the service provider for CustomHelper which Accessable is dependent on aswell as it's own You are also adding a facade for Customhelper, (*2)

"Milkwood\Accessable\AccesableServiceProvider",
"Milkwood\CustomHelper\CustomHelperServiceProvider",

'CH' => 'Milkwood\CustomHelper\CH',

Step 3: Publish Middleware

Via the console, to publish the middlewhere, (*3)

php artisan vendor:publish

You can now use, (*4)

['middleware' => 'auth]

In your routes, (*5)

Step 4: Add Actions To Check For

Add the rules you got for your user, (*6)

protected $keysToCheckFor = ['reqRoles','forbiddenRoles','minAccessLevel','maxAccessLevel','moduleToAccess'];

Step 5: Add The Trait To Class

Add the accessable trait to the class, example the user, (*7)

use Milkwood\Accessable\Accessable;

class ExampleClass{

    use Accessable;

}

Step 6: Create The Rules

See examples below of rules on the usertype below, (*8)

// Requirement functions

public function reqRoles($roles){

    $roles = explode('|',$roles);
    if( in_array( $this->name , $roles) ){
        return true;
    }

    $this->error = 'Din bruger type har ikke adgang til den pÄgÊldende side';
    return false;

}

public function forbiddenRoles($roles){

    $roles = explode('|',$roles);
    if( ! in_array( $this->name , $roles) ){
        return true;
    }

    $this->error = 'Din bruger type er restrikteret fra den pÄgÊldende side';
    return false;

}

public function minAccessLevel($accessLevel){

    if( $this->access_level >= $accessLevel){
        return true;
    }

    $this->error = 'Din brugertype har for lav access til den pÄgÊldende side';
    return false;

}

public function maxAccessLevel($accessLevel){

    if( $this->access_level <= $accessLevel){
        return true;
    }

    $this->error = 'Din brugertype har for hÞj access til den pÄgÊldende side';
    return false;

}

See below for an example of company requirering modules, (*9)

public function moduleToAccess($moduleName){

    $modulesCompanyHasAccessTo = $this->modules->lists('name');

    if( in_array($moduleName, $modulesCompanyHasAccessTo)){
        return true;
    }

    $this->error = 'Din virksomhed har ikke adgang til dette modul';
    return false;

}

See below how to send of the request to another class, (*10)

public function reqRoles($roles){

    return $this->sendOfAccess('userType', [ __FUNCTION__ => $roles]);

}

public function forbiddenRoles($roles){

    return $this->sendOfAccess('userType', [ __FUNCTION__ => $roles]);

}

public function minAccessLevel($accessLevel){

    return $this->sendOfAccess('userType', [ __FUNCTION__ => $accessLevel]);

}

public function maxAccessLevel($accessLevel){

    return $this->sendOfAccess('userType', [ __FUNCTION__ => $accessLevel]);

}

public function moduleToAccess($moduleName){

    return $this->sendOfAccess('company', [ __FUNCTION__ => $moduleName]);

}

The Versions

09/03 2015

dev-master

9999999-dev

  Sources   Download

The Requires

 

by Philip Brechmann

09/03 2015

0.1.6

0.1.6.0

  Sources   Download

The Requires

 

by Philip Brechmann

01/03 2015

0.1.5

0.1.5.0

  Sources   Download

The Requires

 

by Philip Brechmann

01/03 2015

0.1.4

0.1.4.0

  Sources   Download

The Requires

 

by Philip Brechmann

01/03 2015

0.1.2

0.1.2.0

  Sources   Download

The Requires

 

by Philip Brechmann

01/03 2015

0.1.1

0.1.1.0

  Sources   Download

The Requires

 

by Philip Brechmann

01/03 2015

0.1.0

0.1.0.0

  Sources   Download

The Requires

 

by Philip Brechmann