Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
8bafc735c4 | ||
|
1bfd5609a5 | ||
|
602fc14760 | ||
|
eb6ebd635e |
@@ -10,6 +10,8 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"igaster/laravel-theme": "2.0.6",
|
||||
"orchestra/asset": "^3.6"
|
||||
},
|
||||
"require-dev": {
|
||||
},
|
||||
|
6
readme.md
Normal file
6
readme.md
Normal 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' );
|
||||
```
|
@@ -36,6 +36,9 @@
|
||||
@include('adminlte::layouts.partials.scripts')
|
||||
{{-- Scripts --}}
|
||||
{!! Asset::scripts() !!}
|
||||
|
||||
@yield('page-scripts')
|
||||
@show
|
||||
|
||||
</body>
|
||||
</html>
|
@@ -1,6 +1,6 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{{ config('app.name') }} - @yield('htmlheader_title', 'Your title here') </title>
|
||||
<title>{{ config('app.name') }} - @yield('htmlheader_title', 'Your title here')</title>
|
||||
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
|
||||
<!-- CSRF Token -->
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
@@ -29,13 +29,7 @@
|
||||
echo json_encode($trans);
|
||||
@endphp
|
||||
</script>
|
||||
<script src="https://code.highcharts.com/highcharts.js"></script>
|
||||
<style>
|
||||
#favourite.selected {
|
||||
color: orange;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- STYLESHEETS -->
|
||||
{!! Asset::styles() !!}
|
||||
</head>
|
||||
</head>
|
||||
|
@@ -42,6 +42,9 @@
|
||||
</li>
|
||||
@endif
|
||||
|
||||
<!-- Top Menu Items -->
|
||||
@include('adminlte::layouts.partials.topmenu')
|
||||
|
||||
<li class="dropdown user user-menu" id="user_menu">
|
||||
<!-- Menu Toggle Button -->
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
|
@@ -2,12 +2,11 @@
|
||||
|
||||
<!-- JQuery and bootstrap are required by Laravel 5.3 in resources/assets/js/bootstrap.js-->
|
||||
<!-- Laravel App -->
|
||||
<script src="{{ url (mix('/js/app.js')) }}" type="text/javascript"></script>
|
||||
<script src="{{ url(mix('/js/app.js')) }}" type="text/javascript"></script>
|
||||
|
||||
@yield('page-scripts')
|
||||
<!-- Optionally, you can add Slimscroll and FastClick plugins.
|
||||
Both of these plugins are recommended to enhance the
|
||||
user experience. Slimscroll is required when using the
|
||||
fixed layout. -->
|
||||
<script src="{{ url('/plugins/jquery.slimscroll.min.js') }}" type="text/javascript"></script>
|
||||
<script src="{{ url('/plugins/fastclick/fastclick.min.js') }}" type="text/javascript"></script>
|
||||
@js('/site/js/jquery.slimscroll.min.js','jq.slimscroll');
|
||||
@js('/site/js/fastclick.min.js','jq.fastclick');
|
||||
|
@@ -37,7 +37,7 @@
|
||||
</aside>
|
||||
|
||||
@section('page-scripts')
|
||||
<script src="{{ url('/plugins/bootstrap3-typeahead.min.js') }}"></script>
|
||||
@js('/site/js/bootstrap3-typeahead.min.js','bs-typeahead')
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
|
53
src/Controllers/AdminController.php
Normal file
53
src/Controllers/AdminController.php
Normal 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user