Skip to content

Commit

Permalink
logout as admin when logout as user
Browse files Browse the repository at this point in the history
  • Loading branch information
dog-ears committed Nov 17, 2016
1 parent 960fc54 commit 95f97aa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
20 changes: 19 additions & 1 deletion app/Http/Controllers/Auth/AuthController.php
Expand Up @@ -37,7 +37,7 @@ class AuthController extends Controller
*/
public function __construct()
{
$this->middleware($this->guestMiddleware(), ['except' => 'logout']);
$this->middleware($this->guestMiddleware(), ['except' => 'logoutAll']);
}

/**
Expand Down Expand Up @@ -69,4 +69,22 @@ protected function create(array $data)
'password' => bcrypt($data['password']),
]);
}

/**
* If user login as auth too, logout auth and users
*
* @return redirect
*/
protected function logoutAll()
{

//logout as admin
if( \Auth::guard("admin")->check() ){
\Auth::guard("admin")->logout();
}

//logout as user
return( $this->logout() );
}

}
1 change: 1 addition & 0 deletions app/Http/routes.php
Expand Up @@ -16,6 +16,7 @@
});

Route::auth();
$this->get('logout', 'Auth\AuthController@logoutAll');

Route::group(['middleware' => 'auth'], function () {

Expand Down

0 comments on commit 95f97aa

Please sign in to comment.