Skip to content

Commit

Permalink
Removing Unused Code
Browse files Browse the repository at this point in the history
  • Loading branch information
SupianIDz committed Aug 3, 2020
1 parent 1ce6546 commit 107fc12
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/Http/Middleware/SudoMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class SudoMiddleware
* @var string[]
*/
protected $except = [
'octopyid/sudo/signin', 'octopyid/sudo/logout',
'octopyid/sudo/signin',
];

/**
Expand Down
30 changes: 5 additions & 25 deletions src/Sudo.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,31 +52,7 @@ public function signin(int $userId, int $originalUserId)

return $this->auth->loginUsingId($userId);
}

/**
* @return bool
*/
public function logout() : bool
{
if (! $this->hasSudoed()) {
return false;
}

$this->auth->logout();

$originalUserId = $this->app->session->get('octopyid.sudo.original_id');

if ($originalUserId) {
$this->auth->loginUsingId($originalUserId);
}

$this->app->session->forget([
'octopyid.sudo.has_sudoed', 'octopyid.sudo.original_id',
]);

return true;
}


/**
* @param Request $request
* @param Response $response
Expand All @@ -85,6 +61,10 @@ public function logout() : bool
*/
public function modifyResponse(Request $request, Response $response) : Response
{
if (! $this->auth->check()) {
return $response;
}

$sudo = view('sudo::selector', [
'users' => $this->getUsers(),
'hasSudoed' => $this->hasSudoed(),
Expand Down

0 comments on commit 107fc12

Please sign in to comment.