Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to verify $user->hasRole() condition in laravel controller #939

Open
bhattaxay opened this issue Feb 22, 2019 · 0 comments
Open

Comments

@bhattaxay
Copy link

bhattaxay commented Feb 22, 2019

Hello there,

I am using this plugin in laravel, when i put this condition in laravel controller

$user= Auth::user();
if(Auth::user()->hasRole(['owner', 'admin']){
//my code goes here
}else{
return response()->json(['status'=>0,'data'=>'Access Denied'],$this-> accessForbidden);
}

It returns me role instead of return true or false.
Also i want to know one more thing that how exactely Auth::user()->hasRole() is working?
Is it compare user role with existing role in my database? If yes than how?
And let me know how to do this stuff in laravel controller? I know the thing but need to confirm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant