Added admin switch, and composer dependencies

This commit is contained in:
Deon George
2018-05-20 11:57:49 +10:00
parent eb6ebd635e
commit 602fc14760
4 changed files with 63 additions and 2 deletions

View File

@@ -0,0 +1,53 @@
<?php
namespace Leenooks\Controllers;
use App\Http\Controllers\Controller;
use App\User;
use Auth;
use Redirect;
use Session;
class AdminController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
/**
* @todo Change the background color (or something) so we know we are switched
*/
public function user_switch_start($id)
{
if ($this->switch_authorised())
{
$uo = User::find($id);
if (! $uo)
abort(404,'User not found');
Session::put('orig_user',Auth::id());
Auth::login($uo);
}
return Redirect::to('/home');
}
public function user_switch_stop()
{
if ($id = Session::pull('orig_user')) {
$uo = User::find($id);
Auth::login($uo);
}
return Redirect::to('/home');
}
public function switch_authorised()
{
// @todo
return TRUE;
}
}