Skip to content

Commit

Permalink
simplified bits
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenMelbz committed Dec 24, 2017
1 parent e568c44 commit 43925cd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
11 changes: 1 addition & 10 deletions src/Controllers/VueImpersonateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,12 @@

class VueImpersonateController extends Controller {

protected $service;

public function __construct(VueImpersonateService $service)
{
$this->middleware('web');
$this->middleware('auth');
$this->service = $service;
}

public function __invoke(Request $request)
{
if (!optional($request->user())->canImpersonate()) {
return [];
}

return $this->service->getImpersonatable();
return (new VueImpersonateService)->getImpersonatable();
}
}
2 changes: 2 additions & 0 deletions src/resources/js/vue-impersonate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@
const xhr = new XMLHttpRequest();
xhr.open('GET', this.routes.users);
xhr.withCredentials = true;
xhr.setRequestHeader('X-CSRF-TOKEN', document.head.querySelector('meta[name="csrf-token"]').content)
xhr.onload = response => {
Expand Down
5 changes: 3 additions & 2 deletions src/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

Route::get(
'/impersonate/users',
'OwenMelbz\VueImpersonate\Controllers\VueImpersonateController'
)->name('impersonate.users');
'OwenMelbz\VueImpersonate\Controllers\VueImpersonateController')
->name('impersonate.users')
->middleware('web');

0 comments on commit 43925cd

Please sign in to comment.