Giter VIP home page Giter VIP logo

ntrust's People

Contributors

ajmerainfo avatar bostinait avatar fearrr avatar hamid-a avatar jyhsu2000 avatar keyur-spinx avatar klaravel avatar theoxuan avatar zhernakovvladimir 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

ntrust's Issues

Class name must be a valid object or a string

Hi!
When I try to access the permissions of a role, show this error:

Class name must be a valid object or a string

$perms = $ role->perms()->get();

In fact, $role->roleProfile is null

Trait method collision with SoftDeletes

I have this model:

class Admin extends Authenticatable
{
    use Notifiable;

    use SoftDeletes;

    use NtrustUserTrait;
}

And I noticed that there is a collision between NtrustUserTrait and SoftDeletes: the restore method, which both traits has overridden from Model.

image

Am I doing wrong or is this a bug?

Route level if condition else redirects to dashboad.

Hi,

This is not issue, i am asking you a suggestion.

my route:

Route::group(['middleware' => ['permission:roles']], function() { Route::resource("/roles", "RoleController"); });

In this above route working fine but, if a person do not have roles permission it redirects 404 page or dashboard page.

Controller level i can restrict and redirects to dashboard. But i can't understand how to write if condition in route level.

Admin.php

I am following the docs but I am after getting stuck.
After installing via composer and updating provider and alias if I run

$ php artisan ntrust:migration Admin

I get an error Class 'App\Admin' not found

So I $ php artisan create:model Admin

Do I need to manually add the relationships between admin, roles and users here? If so, what relationships or is that up to me?
Admin: belongsTo('App\User') ?
User: hasMany('App\Admin') ?
User: hasMany('App\Role') ?
Admin: hasMany('App\Role') ?

If I run $ php artisan ntrust:migration admin here I can create Tables: admin_roles, admin_role_user, admin_permissions, admin_permission_role

but I try and migrate I get an error

  [Illuminate\Database\QueryException]                                                                  
  SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table `admin_role_user` add constraint `admin_role_user_user_id_foreign` foreign key (`user_id`) references `admins` (`id`) on delete cascade on update cascade)                                                           

  [PDOException]                                                          
  SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint `

Am I doing something wrong or are the docs missing something?
Only admin_roles & admin_role_user get migrated.

Edit role permissions issue

Hi ,
ntrust package is really wonderful . but i have a small issue on this, i am getting below error when i am going to edit a role with added permissions.
{!! Form::select('permissions[]',$permissions,$role->permission->pluck('id'),['id'=>'multiple-checkboxes','multiple'=>true] ) !!}

Call to a member function pluck() on null (View: D:\projects\boom\resources\views\roles\edit.blade.php)

Please help me is am doing any this wrong to call added permissions.

delete role throw error

When deleting role record, an error occurred.

FatalThrowableError in NtrustRoleTrait.php line 95:
Using $this when not in object context

After I check the line 95 of NtrustRoleTrait.php, seems you are calling $this within the static method.

Any solution for that?

Class name must be a valid object or a string

Hi, I am getting this error when trying to determine a user's role running the following code:

$user->hasRole('admin');

I have 2 role types, 'user' and 'admin' and I'm not using permissions.

I am sure this is something I am doing incorrectly but since I saw the last thread was left unopen I thought I should post.

User Model:

fyi?

  1. Is this support multiple user role for one user?
  2. Can we manage user permissions and manage roles for user side and admin side?

Multi Auth migration create

I'm using Laravel 5.3 multiauth guards.
I have edited ntrust.php in config directory.
When I run php artisan ntrust:migration admin or php artisan ntrust:migration user
it creates migrations with not admin_user_id or site_user_id it creates with default value user_id.

Same with role_id and permission_id

@role('admin')

@ROLE('admin')

get ErrorException
Parse error: syntax error, unexpected ''admin'' (T_CONSTANT_ENCAPSED_STRING) (View: ...

Access to undeclared static property: $staticRoleProfile

I found this error when trying to delete a model with SoftDeletes.
This property is not declared in the model documentation and it refers to the boot method in the NtrustUserTrait.


    public static function boot()
    {
        parent::boot();

        static::deleting(function($user) {
            if (!method_exists(Config::get('ntrust.profiles.' . self::$staticRoleProfile . '.model'), 'bootSoftDeletes')) {
                $user->roles()->sync([]);
            }

            return true;
        });
    }

However, it works just by adding the property with the same profile as the non static $roleProfile

 protected $roleProfile = 'user';
 protected static $staticRoleProfile = 'user';

Should i keep the model like that? or is there any other workaround?
I saw this issue closed and the user said he just restarted the configuration, but it doesn´t work for me
issue/20

Call to undefined method Illuminate\Database\Query\Builder::restored()

This problem happens in the current state of master branch.

Here is the stack trace:

    1. in Builder.php line 2448
    2. at Builder->__call('restored', array(object(Closure)))
    3. at call_user_func_array(array(object(Builder), 'restored'), array(object(Closure))) in Builder.php line 1465
    4. at Builder->__call('restored', array(object(Closure)))
    5. at call_user_func_array(array(object(Builder), 'restored'), array(object(Closure))) in Model.php line 3551
    6. at Model->__call('restored', array(object(Closure)))
    7. at call_user_func_array(array(object(User), 'restored'), array(object(Closure))) in Model.php line 3565
    8. at Model::__callStatic('restored', array(object(Closure))) in NtrustUserTrait.php line 81
    9. at User::bootObservers() in NtrustUserTrait.php line 45
    10. at User::boot() in Model.php line 296
    11. at Model->bootIfNotBooted() in Model.php line 277
    12. at Model->__construct() in EloquentUserProvider.php line 130
    13. at EloquentUserProvider->createModel() in EloquentUserProvider.php line 47
    14. at EloquentUserProvider->retrieveById('1') in SessionGuard.php line 132
    15. at SessionGuard->user() in GuardHelpers.php line 35
    16. at SessionGuard->authenticate() in AuthManager.php line 294
    17. at AuthManager->__call('authenticate', array()) in Authenticate.php line 57
    18. at Authenticate->authenticate(array()) in Authenticate.php line 41
    19. at Authenticate->handle(object(Request), object(Closure)) in Pipeline.php line 137
    20. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
    21. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 65
    22. at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 137
    23. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
    24. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
    25. at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
    26. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
    27. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
    28. at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
    29. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
    30. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
    31. at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 137
    32. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
    33. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
    34. at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 137
    35. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
    36. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
    37. at Pipeline->then(object(Closure)) in Router.php line 644
    38. at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 618
    39. at Router->dispatchToRoute(object(Request)) in Router.php line 596
    40. at Router->dispatch(object(Request)) in Kernel.php line 267
    41. at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
    42. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Debugbar.php line 51
    43. at Debugbar->handle(object(Request), object(Closure)) in Pipeline.php line 137
    44. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
    45. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
    46. at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
    47. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
    48. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
    49. at Pipeline->then(object(Closure)) in Kernel.php line 149
    50. at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116
    51. at Kernel->handle(object(Request)) in index.php line 53
    52. at require_once('/home/aterbonus/prueba/public/index.php') in server.php line 21

The problem is caused by this when the user model doesn't have the SoftDeletes trait.

Is a requirement to use ntrust to have the SoftDeletes trait in the user model?

error in ntrust:migration

why when i run in terminal
php artisan ntrust:migration user

it always throw an error like this:
[Symfony\Component\Debug\Exception\FatalThrowableError] Parse error: syntax error, unexpected '*', expecting function (T_FUNCTION)

anyone can help me?

No admin table ?

After installed, some tables are added to the database, but no admins. I see \config\ntrust.php has
'table' => 'admins',
model' => 'App\Models\Admin',

In your migrations file xxx_admin_ntrust_setup_tables.php, there is admin_permission_role, admin_permissions, admin_role_user, admin_roles. But no admins ??

$roleProfile variable is not present in user object

As mentioned in readme.md, I updated User model with protected static $roleProfile = 'user'; but it's not present in the user object. If I use without static, the variable is present in user object.

Since the static variable is not working I get Class name must be a valid object or a string error. Laravel version is 5.3.29

Please advice

Access to undeclared static property User::$staticRoleProfile

I'm trying to remove users from database, so in my controller I do:

$ User = User :: find ($ id);
$ User-> delete ();

But I am always getting the error: "Access to undeclared static property User :: $ staticRoleProfile"

Someone can help me? I'm very noob with PHP / Laravel (I do not know if it's a complex problem or not, sorry).

Thanks a lot.

attachRole does not working

I have existing role, and I'm trying to save that role to user
$user = User::find(1);//working
$role = Role::where('id', '=', 1)->first();//working
$user->attachRole($role);

Access to undeclared static property

After update to new version, i get this

ErrorException in \vendor\klaravel\ntrust\src\Ntrust\Traits\NtrustUserTrait.php line 14:

Access to undeclared static property: App\User::$roleProfile 
(View: ..\resources\views\sections\menu.blade.php)

in view i use

@role('admin')
@endrole

@role(['creator', 'moderator'])
@endrole

@role('user')
@endrole

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.