GithubHelp home page GithubHelp logo

entrust's People

Contributors

aglipanci avatar andrew13 avatar andrewelkins avatar bbatsche avatar dboskovic avatar dzcpy avatar edwin-karanja avatar emir avatar gayanhewa avatar gnanakeethan avatar grahamcampbell avatar jacq avatar jobrios avatar jolamar avatar michaeljhopkins avatar micheleangioni avatar miscbits avatar mvestil avatar poma avatar rodriguezmuller avatar soupdiver avatar thefuzzy0ne avatar tonglil avatar unitedworx avatar unnawut avatar vkarampinis avatar vpratfr avatar yamenarahman avatar yelldon avatar zizaco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

entrust's Issues

Issue saving permissions

When I save permissions it's saving it in the format {4:'permission_here'}
When I attempt to reference that:

        // Get current user and check permission
        $user = Confide::user();
        $canComment = false;
        if(!empty($user)) {
            $canComment = $user->can('permission_here');
        }

It comes back with false.
If the permission is saved as: ["permission_here"]
It will come back true.

See: andrewelkins/Laravel-4-Bootstrap-Starter-Site#38

I'll investigate later.

EntrustRole->name length limitation

Why is rolename limited to 16 chars? Since database migration creates a string column ( -> varchar(255)), this limitation seems unnecessary?
I propose to either remove the limitation, or at least mention it in the readme.

Custom table names or prefix

It would be nice to have posibility to define table names or prefixes.
For example those names could be:

  • cb_roles
  • cb_permissions
  • cb_permission_role
  • cb_assigned_roles

Disregard

I had a minor typo. Sorry to clutter things up.

The Response content must be a string or object implementing __toString(), "object" given.

The Response content must be a string or object implementing __toString(), "object" given.

I get this issue when using closures in Entrust::routeNeedsRole third param.

Entrust::routeNeedsRole('admin*', array('SuperAdmin', 'Admin'), function() {
Session::put('loginRedirect', Request::url());
Session::put('error', 'You must login to view that page.');
return Redirect::to(URL::route('login'));
}
);

Any ideas?

PHP 5.4 requirement

Is there something I can change in order to use your package in PHP 5.3.x?

Permissions without roles?

Hey,

is there a way to add permissions to a user without adding a specific role for them?
For example if i want to add permissions for "Modules" (User A has the right to view Module "Documents", User B not - without adding a Role for every Module?)

Should i just create a role for every user?

Thanks.

Suggestion: Add a permission table

So instead of
$owner->permissions = array('manage_posts','manage_pages','manage_users');

$owner->permissions = array(2,5,6);// where those are the ids of the permissions in the permission table.

    // Creates the permissions table
    Schema::create('permissions', function($table)
    {
        $table->increments('id');
        $table->string('name');
        $table->timestamps();
    });

I say this because in a system where you are creating roles from an admin screen you would likely want to see what permissions are available for two reasons.

  1. To see what permissions to add to the new role.
  2. See if you need to add a new permission.

Currently one would have to parse all of the permission fields, combine them and then spit out the permissions currently used in the system.

With the new table / model, within a controller it would be as easy as:

    $permissions = Permissions::all();

Then in the view something like:

    <select>
    @foreach ($permissions as $permission)
         <option value="{{$permission->id}}">{{$permission->name}}</option>
    @endforeach
    </select>

Functions to Get a User's Role and Permissions

Are there functions within Entrust to get a $user objects roles and/or permissions?

I'm trying to print to screen what assigned role the user is and his/her associated permissions...

Thanks,

-Luke

Mock Entrust

Hi, i'm noob in testing and I was wondering how to mock Entrust, because in my view I have this statement: @if ( Entrust::hasRole('Admin') )

I try with Entrust::shouldReceive but I get:

PHP Fatal error: Call to undefined method Zizaco\Entrust\Entrust::shouldReceive()

Update user's role, fails with `column not found error`

I kept trying to figure it out, why sync() user roles won't have a go, with the following error:

  SQLSTATE[42S22]: Column not found: 1054 Unknown column 'eloquent_users_repository_id' in 'where clause' (SQL: select `role_id` from `assigned_roles` where `eloquent_users_repository_id` = ?) (Bindings: array ( 0 => '3', ))

My models, are just like those from https://github.com/andrew13/Laravel-4-Bootstrap-Starter-Site

I just can't figure out, what goes wrong. Any ideas?

Permissions stored in the db

I might be nice to store permissions in the db as well. Have a permissions table and then the roles table would reference individual permission ids.

The advantage being you gain more flexibility on the admin side of things. Each permission could then have a name for displaying in an admin panel. Or description field for an explanation of what the permission does.

Trait causing weird error

When using hasRole as trait (if I copy the code in to the role everything works), it causes the Auth class to be buggy. Chrome console logs the error: failed to load ressource CURRENT_FILE:LAST_LINE i.e. failed to load ressources localhost:8000/login.

And this causes javascript to stop working if you put it in to the footer (where 99% of javascript belongs).

why not just use a class like you do in the roles?

requires php >=5.4.0 -> no matching package found

I'm running Laravel on my local machine with PHP 5.4.10 installed. When I run:

composer update

I get this message:

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1

  • Installation request for zizaco/entrust dev-master -> satisfiable by zizaco/entrust[dev-master].
  • zizaco/entrust dev-master requires php >=5.4.0 -> no matching package found.

Potential causes:

"composer update" works fine if I remove out "zizaco/entrust": "dev-master" from "require" in composer.json.

My PHP version is as follow:

php -v
PHP 5.4.10 (cli) (built: Jan 21 2013 15:12:32)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
with XCache v2.0.1, Copyright (c) 2005-2012, by mOo
with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans

Entrust::routeNeedsRole etc should also accept route names

Now you can only add a route path, but when using resource controllers you are unable to add a Entrust::routeNeedsRole etc since the path is the same. only the http method is different.

If these types of methods accept route names this will not be an issue anymore since the route names of a resource controller are all different.

Composer Update with Laravel 4

vendor/zizaco/entrust/src/commands/MigrationCommand.php on line 31

[code]
"error":{"type":"Symfony\Component\Debug\Exception\FatalErrorException","message":"parse error","file":"/Applications/MAMP/htdocs/portall4.dev/vendor/zizaco/entrust/src/commands/MigrationCommand.php","line":31}}Script php artisan clear-compiled handling the pre-update-cmd event returned with an error

[RuntimeException]
Error Output: PHP Parse error: parse error in /Applications/MAMP/htdocs/po
rtall4.dev/vendor/zizaco/entrust/src/commands/MigrationCommand.php on line
31

[/code]

Solution:
remove the pre-update scripts from composer.json

How to solve the problem to let pre-update scripts active?

assigned_roles table

Hello,

While checking assigned_roles table I've noticed that it's being setup inefficiently.

Currently the table has 3 fields (id, user_id, role_id), of which only ID is PRIMARY.

I'd suggest making assigned_roles table consist of references to user_id and role_id (in the respective tables) and having both (user_id and role_id) fields as PRIMARY keys for faster lookups.

Code for table creation below:

CREATE  TABLE IF NOT EXISTS `database`.`assigned_roles` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT ,
  `user_id` INT(10) UNSIGNED NOT NULL ,
  `role_id` INT(10) UNSIGNED NOT NULL ,
  PRIMARY KEY (`id`, `user_id`, `role_id`) ,
  INDEX `fk_assigned_roles_users1_idx` (`user_id` ASC) ,
  INDEX `fk_assigned_roles_roles1_idx` (`role_id` ASC) ,
  CONSTRAINT `fk_assigned_roles_users1`
    FOREIGN KEY (`user_id` )
    REFERENCES `database`.`users` (`id` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_assigned_roles_roles1`
    FOREIGN KEY (`role_id` )
    REFERENCES `database`.`roles` (`id` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
AUTO_INCREMENT = 3
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_unicode_ci

Allow for a more flexible model

It would be nice if the table and field names could be customized, either through config params or via object properties. As it is now, it is a bit cumbersome to do this, as you have to extend entire methods.

Routes Needs Role (multiple roles) not working

 Entrust::routeNeedsRole( 'admin*', array('admin','restaurateur'), Redirect::to('/') );

Is not working. As an admin, it redirects to / and as a restaurateur it redirets to /.
But if I just put admin or restaurateur, it works just fine...

Any ideas why?

Thanks,
Ara

Is it really required php 5.4?

If still working on 5.3 won't be able to install this via composer.

Many hosting providers do not offer 5.4 yet, is this a really needed feature?

Route Parameters + Permissions

I'm trying to filter a route with parameters, but it doesn't seem to work, as i thought.
Here is my route from routes.php:
Route::get('client/{slug}/thing/create', ThingController@create' );

Here is my filter from filters.php:
Entrust::routeNeedsPermission( 'client/{slug}/thing/create','manage_things');

But this filter is not working. Any ideas or hints?

migration.blade bug

To avoid the migration issue between Entrust and Confide

27 - $table->integer('user_id')->unsigned();

29 - $table->integer('role_id')->unsigned();

Easier usage for protecting a route

I would love to have a function which that i can protect the current route and which i can call in the Controller function, something like:

public function getIndex()
{
    Entrust::needed('manage_users');
}

So as soon as i hit the route Entrust will check for access and redirect or abort if the permission is not given.

We can do that with a custom function in the Basecontroller but a native function would be nice.

Four char limit on Role names

Hi,

I know it's easy to override the length limit of Role-names, but is it set to 4 by any particular reason?

For anyone having trouble with saving Role's with less than 4 characters, add, and modify, this to your own Role.php model file:

    /**
     * Ardent validation rules
     *
     * @var array
     */
    public static $rules = array(
        'name' => 'required|between:3,16'
    );

Error migrate:refresh

When I run: php artisan migrate:refresh I got:

PHP Fatal error: Class 'CreateRolesTable' not found in /var/www/karelWeb/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php on line 301
{"error":{"type":"Symfony\Component\Debug\Exception\FatalErrorException","message":"Class 'CreateRolesTable' not found","file":"/var/www/karelWeb/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php","line":301}}

Anyone knows about this problem?

EntrustRole - failed to open stream

I've followed the instructions to install Entrust. I'm getting hung up on this error when trying to run the app. I'm using laravel 4.0.9:

include(/Users/myuser/Documents/workspace/myapp/app/models/Role.php use Zizaco/Entrust/EntrustRole; class Role extends EntrustRole { }.php): failed to open stream: No such file or directory

I've given my entire app read/write access to everyone and this is a fresh install of Laravel.

My Role model looks like this:

true, /* |-------------------------------------------------------------------------- | Application URL |-------------------------------------------------------------------------- | | This URL is used by the console to properly generate URLs when using | the Artisan command line tool. You should set this to the root of | your application so that it is used when running Artisan tasks. | */ 'url' => 'http://localhost', /* |-------------------------------------------------------------------------- | Application Timezone |-------------------------------------------------------------------------- | | Here you may specify the default timezone for your application, which | will be used by the PHP date and date-time functions. We have gone | ahead and set this to a sensible default for you out of the box. | */ 'timezone' => 'UTC', /* |-------------------------------------------------------------------------- | Application Locale Configuration |-------------------------------------------------------------------------- | | The application locale determines the default locale that will be used | by the translation service provider. You are free to set this value | to any of the locales which will be supported by the application. | */ 'locale' => 'en', /* |-------------------------------------------------------------------------- | Encryption Key |-------------------------------------------------------------------------- | | This key is used by the Illuminate encrypter service and should be set | to a random, 32 character string, otherwise these encrypted strings | will not be safe. Please do this before deploying an application! | */ 'key' => 'IhmsKHycqz7logrKtJOO4s0olnewRL0n', /* |-------------------------------------------------------------------------- | Autoloaded Service Providers |-------------------------------------------------------------------------- | | The service providers listed here will be automatically loaded on the | request to your application. Feel free to add your own services to | this array to grant expanded functionality to your applications. | */ 'providers' => array( 'Illuminate\Foundation\Providers\ArtisanServiceProvider', 'Illuminate\Auth\AuthServiceProvider', 'Illuminate\Cache\CacheServiceProvider', 'Illuminate\Foundation\Providers\CommandCreatorServiceProvider', 'Illuminate\Session\CommandsServiceProvider', 'Illuminate\Foundation\Providers\ComposerServiceProvider', 'Illuminate\Routing\ControllerServiceProvider', 'Illuminate\Cookie\CookieServiceProvider', 'Illuminate\Database\DatabaseServiceProvider', 'Illuminate\Encryption\EncryptionServiceProvider', 'Illuminate\Filesystem\FilesystemServiceProvider', 'Illuminate\Hashing\HashServiceProvider', 'Illuminate\Html\HtmlServiceProvider', 'Illuminate\Foundation\Providers\KeyGeneratorServiceProvider', 'Illuminate\Log\LogServiceProvider', 'Illuminate\Mail\MailServiceProvider', 'Illuminate\Foundation\Providers\MaintenanceServiceProvider', 'Illuminate\Database\MigrationServiceProvider', 'Illuminate\Foundation\Providers\OptimizeServiceProvider', 'Illuminate\Pagination\PaginationServiceProvider', 'Illuminate\Foundation\Providers\PublisherServiceProvider', 'Illuminate\Queue\QueueServiceProvider', 'Illuminate\Redis\RedisServiceProvider', 'Illuminate\Auth\Reminders\ReminderServiceProvider', 'Illuminate\Foundation\Providers\RouteListServiceProvider', 'Illuminate\Database\SeedServiceProvider', 'Illuminate\Foundation\Providers\ServerServiceProvider', 'Illuminate\Session\SessionServiceProvider', 'Illuminate\Foundation\Providers\TinkerServiceProvider', 'Illuminate\Translation\TranslationServiceProvider', 'Illuminate\Validation\ValidationServiceProvider', 'Illuminate\View\ViewServiceProvider', 'Illuminate\Workbench\WorkbenchServiceProvider', 'Zizaco\Entrust\EntrustServiceProvider', ), /* |-------------------------------------------------------------------------- | Service Provider Manifest |-------------------------------------------------------------------------- | | The service provider manifest is used by Laravel to lazy load service | providers which are not needed for each request, as well to keep a | list of all of the services. Here, you may set its storage spot. | */ 'manifest' => storage_path().'/meta', /* |-------------------------------------------------------------------------- | Class Aliases |-------------------------------------------------------------------------- | | This array of class aliases will be registered when this application | is started. However, feel free to register as many as you wish as | the aliases are "lazy" loaded so they don't hinder performance. | */ 'aliases' => array( 'App' => 'Illuminate\Support\Facades\App', 'Artisan' => 'Illuminate\Support\Facades\Artisan', 'Auth' => 'Illuminate\Support\Facades\Auth', 'Blade' => 'Illuminate\Support\Facades\Blade', 'Cache' => 'Illuminate\Support\Facades\Cache', 'ClassLoader' => 'Illuminate\Support\ClassLoader', 'Config' => 'Illuminate\Support\Facades\Config', 'Controller' => 'Illuminate\Routing\Controllers\Controller', 'Cookie' => 'Illuminate\Support\Facades\Cookie', 'Crypt' => 'Illuminate\Support\Facades\Crypt', 'DB' => 'Illuminate\Support\Facades\DB', 'Eloquent' => 'Illuminate\Database\Eloquent\Model', 'Event' => 'Illuminate\Support\Facades\Event', 'File' => 'Illuminate\Support\Facades\File', 'Form' => 'Illuminate\Support\Facades\Form', 'Hash' => 'Illuminate\Support\Facades\Hash', 'HTML' => 'Illuminate\Support\Facades\HTML', 'Input' => 'Illuminate\Support\Facades\Input', 'Lang' => 'Illuminate\Support\Facades\Lang', 'Log' => 'Illuminate\Support\Facades\Log', 'Mail' => 'Illuminate\Support\Facades\Mail', 'Paginator' => 'Illuminate\Support\Facades\Paginator', 'Password' => 'Illuminate\Support\Facades\Password', 'Queue' => 'Illuminate\Support\Facades\Queue', 'Redirect' => 'Illuminate\Support\Facades\Redirect', 'Redis' => 'Illuminate\Support\Facades\Redis', 'Request' => 'Illuminate\Support\Facades\Request', 'Response' => 'Illuminate\Support\Facades\Response', 'Route' => 'Illuminate\Support\Facades\Route', 'Schema' => 'Illuminate\Support\Facades\Schema', 'Seeder' => 'Illuminate\Database\Seeder', 'Session' => 'Illuminate\Support\Facades\Session', 'Str' => 'Illuminate\Support\Str', 'URL' => 'Illuminate\Support\Facades\URL', 'Validator' => 'Illuminate\Support\Facades\Validator', 'View' => 'Illuminate\Support\Facades\View', 'Entrust' => 'Zizaco\Entrust\EntrustFacade', ), ``` ); And this is what my routes.php looks like: name = 'Owner'; $owner->save(); $admin = new Role; $admin->name = 'Admin'; $admin->save(); $user = User::where('email','=','[email protected]')->first(); /\* role attach alias */ $user->attachRole( $admin ); // Parameter can be an Role object, array or id. /\* OR the eloquent's original: */ $user->roles()->attach( $admin->id ); // id only $managePosts = new Permission; $managePosts->name = 'manage_posts'; $managePosts->display_name = 'Manage Posts'; $managePosts->save(); $manageUsers = new Permission; $manageUsers->name = 'manage_users'; $manageUsers->display_name = 'Manage Users'; $manageUsers->save(); $owner->perms()->sync(array($managePosts->id,$manageUsers->id)); $admin->perms()->sync(array($managePosts->id)); $user->hasRole("Owner"); // false $user->hasRole("Admin"); // true $user->can("manage_posts"); // true $user->can("manage_users"); // false });

Can't install

I'm on my local dev environment and I'm definitely running PHP 5.4.14

When I run composer update, I get this error:

Your requirements could not be resolved to an installable set of packages.

Problem 1
- Installation request for zizaco/entrust dev-master -> satisfiable by zizaco/entrust[dev-master].
- zizaco/entrust dev-master requires php >=5.4.0 -> no matching package found.

Potential causes:

  • A typo in the package name
  • The package is not available in a stable-enough version according to your minimum-stability setting

Still doing research to figure out what causes it.

Polymorphic permissions

Might be nice to be able to have permissions specified against multiple types of data.

Either by class (id column is null), or instance (id column is not null).

Also global permissions are possible by having both class and id as null.

See this rails package for an idea as to how useful it can be: http://eppo.github.com/rolify/

Adding permissions to a role

Hi all,

This is a "proposal issue".

Currently permission assignment to a role requires knowledge of the permission_id attribute and the savePermissions method call. This is what I learned from documentation and the code; Please correct me if I am wrong.

What if permissions assignment will be done by permission name and on calling method save, so it will look more intuitive for the developers?

An example:

$role = new Role;
$role->permissions = [ 'blog.post.add', 'blog.post.edit' ];
$role->save();

This code will try to find permissions "blog.post.add" and "blog.post.edit" by name and assign them to the role on saving the role (this will use pivotal table, of course).

I have already implemented this in my project and wondering if you are interesting in the same behavior. I can do a pull request sometime this weekend if you do.

Composer update throws errors on fresh install of laravel (Can't Install)

I have a fresh install of laravel and I'm trying to include Entrust. I've modified the database config to connect to an empty database for the project. Everything else is untouched. I'm on osx 10.9.

My composer.json require section looks like this:

"require": {
    "laravel/framework": "4.1.*",
    "zizaco/entrust": "dev-master"
},

When I do composer update this is what I get:

$composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Installation request for laravel/framework 4.1.8 -> satisfiable by laravel/framework[v4.1.8].
- zizaco/entrust dev-master requires illuminate/support 4.0.x -> satisfiable by laravel/framework[4.0.x-dev, v4.0.0, v4.0.0-BETA2, v4.0.0-BETA3, v4.0.0-BETA4, v4.0.1, v4.0.10, v4.0.2, v4.0.3, v4.0.4, v4.0.5, v4.0.6, v4.0.7, v4.0.8, v4.0.9], illuminate/support[4.0.x-dev, v4.0.0, v4.0.0-BETA2, v4.0.0-BETA3, v4.0.0-BETA4, v4.0.1, v4.0.10, v4.0.2, v4.0.3, v4.0.4, v4.0.5, v4.0.6, v4.0.7, v4.0.8, v4.0.9].
- Can only install one of: laravel/framework[v4.1.8, 4.0.x-dev].
- Can only install one of: laravel/framework[v4.1.8, v4.0.0].
- Can only install one of: laravel/framework[v4.1.8, v4.0.0-BETA2].
- Can only install one of: laravel/framework[v4.1.8, v4.0.0-BETA3].
- Can only install one of: laravel/framework[v4.1.8, v4.0.0-BETA4].
- Can only install one of: laravel/framework[v4.1.8, v4.0.1].
- Can only install one of: laravel/framework[v4.1.8, v4.0.10].
- Can only install one of: laravel/framework[v4.1.8, v4.0.2].
- Can only install one of: laravel/framework[v4.1.8, v4.0.3].
- Can only install one of: laravel/framework[v4.1.8, v4.0.4].
- Can only install one of: laravel/framework[v4.1.8, v4.0.5].
- Can only install one of: laravel/framework[v4.1.8, v4.0.6].
- Can only install one of: laravel/framework[v4.1.8, v4.0.7].
- Can only install one of: laravel/framework[v4.1.8, v4.0.8].
- Can only install one of: laravel/framework[v4.1.8, v4.0.9].
- don't install illuminate/support 4.0.x-dev|don't install laravel/framework v4.1.8
- don't install illuminate/support v4.0.0|don't install laravel/framework v4.1.8
- don't install illuminate/support v4.0.0-BETA2|don't install laravel/framework v4.1.8
- don't install illuminate/support v4.0.0-BETA3|don't install laravel/framework v4.1.8
- don't install illuminate/support v4.0.0-BETA4|don't install laravel/framework v4.1.8
- don't install illuminate/support v4.0.1|don't install laravel/framework v4.1.8
- don't install illuminate/support v4.0.10|don't install laravel/framework v4.1.8
- don't install illuminate/support v4.0.2|don't install laravel/framework v4.1.8
- don't install illuminate/support v4.0.3|don't install laravel/framework v4.1.8
- don't install illuminate/support v4.0.4|don't install laravel/framework v4.1.8
- don't install illuminate/support v4.0.5|don't install laravel/framework v4.1.8
- don't install illuminate/support v4.0.6|don't install laravel/framework v4.1.8
- don't install illuminate/support v4.0.7|don't install laravel/framework v4.1.8
- don't install illuminate/support v4.0.8|don't install laravel/framework v4.1.8
- don't install illuminate/support v4.0.9|don't install laravel/framework v4.1.8
- Installation request for zizaco/entrust dev-master -> satisfiable by zizaco/entrust[dev-master].

403 instead of 404

I just noticed that you use a HTTP 404 error when a user hasn't the right permissions. A 404 means "Not found", but in fact the page is found, but the user just hasn't the right permission. I suggest you use the 403 wich means "Forbidden".

More of a Custom Addition

Someone asked me if they could have a different denied message for staff members vs guests and regular members...

Route::filter('userAdmin',function() {
if (!Entrust::hasRole('userAdmin')) {
// The problem lied here
App::abort('404');
}
});

I could do one of two things...

if (Auth::check()) {
if (Auth::User()->roles) {
App::abort('permissionDenied');
}
}

or a function in Entrust.php

function hasRoles() {
$user = $this->user;

if ($user) {
return $user->roles;
}
return false;
}

this would give me the ability to run

Route::filter('userAdmin',function() {
if (!Entrust::hasRole('userAdmin')) {
if (Entrust::hasRoles()) {
App::abort('permissionDenied');
}
App::abort('404');
}

});

instead of having to use the ability() function and list ALL of my roles individually especially if one changed.

Couldnot load this package..

Loading composer repositories with package information
Installing dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Installation request for zizaco/entrust dev-master -> satisfiable by zizac
o/entrust[dev-master].
- zizaco/entrust dev-master requires php >=5.4.0 -> no matching package foun
d.

Potential causes:

Read http://getcomposer.org/doc/articles/troubleshooting.md for further common
problems.

When i run composer intall to include your package it could not take it..
what is the problem โœŒ๏ธ Thank you

Can't run $user->attachRole in seed

I can't for the life of me get the seeder to attach roles.

I've followed your README, and have included the Entrust package in my user model and seeder file, yet it still gives the error...

when running:

$ php artisan db:seed --env="local"
Call to undefined method Illuminate\Database\Query\Builder::attachRole()

running it from

RolesTableSeeder.php

<?php
use Zizaco\Entrust\EntrustRole;
use Zizaco\Entrust\HasRole;
class RolesTableSeeder extends Seeder {
    use HasRole;

    public function run()
    {
        DB::table('roles')->delete();
        DB::table('assigned_roles')->delete();

        $admin_role = new Role;
        $admin_role->name = 'Admin';
        $admin_role->permissions = array('manage_settings', 'manage_users', 'view_adminarea', 'manage_posts', 'manage_questions');
        $admin_role->save();

        $user = User::where('username','=','admin')->first();
        $user->attachRole( $admin_role);

    }

}

Any idea as to where I'm screwing up? Any and all help greatly appreciated!

problem with namespaced models

Hi , i am just starting with laravel. So maybe this doesnt make much sense.
Because someone told me its a good practice to namespace you classes i am also namespacing my models. So both, User and Role are using "namespace Models;"
But when i do so, i get an error class 'Role' no found.
If i remove the namespace from Role.php it seems to work fine.
Am i doing something wrong or is entrust not working with my namespaced models ?

thanks

Tagged releases

Hi

Just looking into Confide but I notice the last tagged release is 6 months old. Is that the latest stable code?

Saving new role fails with not null contraint violation

When creating a new role as describe in Usage > concepts section of the docs:

$admin = new Role;
$admin->name = "Administrador";
$admin->save();

And running it as part of my seeder, I get this error:

[Exception]
SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column "permissions" violates
not-null constraint (SQL: insert into "roles" ("name", "updated_at", "created_at") values (
?, ?, ?) returning "id") (Bindings: array (
0 => 'Administrador',
1 => '2013-10-28 04:58:22',
2 => '2013-10-28 04:58:22',
))

So basically it does not work as specified in the docs.

A problem with route null/redirection

When I use this:

Entrust::routeNeedsPermission('admin/roles*', 'config_manage');

I get an HttpException and 500 Internal Server Error. When I use this:

Entrust::routeNeedsPermission('admin/roles*', 'config_manage',
Redirect::to('admin')->with('message', array(
'type' => 'warning',
'content' => 'No permissions for this resource'
)));

then the flash message appears on every click on the website.

I'm using Laravel 4.0 with the latest updates.

Using $this when not in object context (PHP -v 5.3.26 shared hosting)

Hi, This happen when I deploy my app in the server production, I see similar issues but the others was fixed, I dot'n know if is a php version problem or a configuration problem, is the classic "locally works".

$filter_name = implode('_',$roles).'_'.substr(md5($route),0,6);

    if (! $result instanceof Closure) {
        $result = function() use ($roles, $result, $cumulative) {
            $hasARole = array();
            foreach($roles as $role) {
                if ($this->hasRole($role)) {
                    $hasARole[] = true;
                } else {

Thanks beforehand.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.