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

@ -10,6 +10,8 @@
} }
], ],
"require": { "require": {
"igaster/laravel-theme": "2.0.6",
"orchestra/asset": "^3.6"
}, },
"require-dev": { "require-dev": {
}, },

6
readme.md Normal file
View File

@ -0,0 +1,6 @@
* User Switch
Add the following routes
```
Route::get( 'admin/switch/start/{id}', 'UserController@user_switch_start' );
Route::get( 'admin/switch/stop', 'UserController@user_switch_stop' );
```

View File

@ -9,5 +9,5 @@
Both of these plugins are recommended to enhance the Both of these plugins are recommended to enhance the
user experience. Slimscroll is required when using the user experience. Slimscroll is required when using the
fixed layout. --> fixed layout. -->
<script src="{{ url('/plugins/jquery.slimscroll.min.js') }}" type="text/javascript"></script> @js('site/js/jquery.slimscroll.min.js','jq.slimscroll');
<script src="{{ url('/plugins/fastclick/fastclick.min.js') }}" type="text/javascript"></script> @js('site/js/fastclick.min.js','jq.fastclick');

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;
}
}