Skip to content

Commit

Permalink
Merge pull request #1 from pszucs/reproduce-issue-378
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephSilber authored Jan 20, 2019
2 parents 68e368e + faab920 commit 8301307
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class UsersController extends Controller
{
public function index()
{
$this->authorize('view', User::class);
// $this->authorize('view', User::class);

return User::all();
}
Expand Down
14 changes: 13 additions & 1 deletion database/seeds/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ class DatabaseSeeder extends Seeder
*/
public function run()
{
factory(User::class)->create()->allow('view', User::class);
// Bouncer::ability()->create([
// 'name' => 'read-users'
// ]);
Bouncer::allow('superadmin')->everything();

$user = User::create([
'name' => 'Bouncer Test',
'email' => 'test@example.org',
'password' => 'supersecretpwd'
]);

// Bouncer::allow($user)->to('read-users');
Bouncer::assign('superadmin')->to($user);
}
}
10 changes: 9 additions & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,12 @@
|
*/

Route::get('users', 'UsersController@index');
Route::middleware(['auth'])->group(function () {
Route::group([
'middleware' => ['can:read-users'],
'prefix' => 'users',
'as' => 'users.'
], function () {
Route::get('/', ['as' => 'index', 'uses' => 'UsersController@index']);
});
});

0 comments on commit 8301307

Please sign in to comment.