Enhancements to user switch
This commit is contained in:
parent
b0fcdaa375
commit
ac867a2526
@ -136,4 +136,5 @@ return [
|
|||||||
'loggedin' => 'Logged in!',
|
'loggedin' => 'Logged in!',
|
||||||
'entering' => 'Entering...',
|
'entering' => 'Entering...',
|
||||||
'registered' => 'User Registered!',
|
'registered' => 'User Registered!',
|
||||||
|
'switchoff' => 'Switch Back',
|
||||||
];
|
];
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<div id="app" v-cloak>
|
<div id="app" v-cloak>
|
||||||
<div class="register-box">
|
<div class="register-box">
|
||||||
<div class="register-logo">
|
<div class="register-logo">
|
||||||
<a href="{{ url('/home') }}"><b>Pipeline</b>Management</a>
|
<a href="{{ url('/home') }}">{!! config('app.name_html_long') !!}</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if (count($errors) > 0)
|
@if (count($errors) > 0)
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
<!-- Top Menu Items -->
|
<!-- Top Menu Items -->
|
||||||
@include('adminlte::layouts.partials.topmenu')
|
@include('adminlte::layouts.partials.topmenu')
|
||||||
|
|
||||||
<li class="dropdown user user-menu" id="user_menu">
|
<li class="dropdown user user-menu @if($user->switched()) bg-red @endif" id="user_menu">
|
||||||
<!-- Menu Toggle Button -->
|
<!-- Menu Toggle Button -->
|
||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||||
<!-- The user image in the navbar-->
|
<!-- The user image in the navbar-->
|
||||||
@ -69,16 +69,22 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<a href="{{ url('/logout') }}" class="btn btn-default btn-flat" id="logout"
|
@if ($user->switched())
|
||||||
onclick="event.preventDefault();
|
<a href="{{ url('/admin/switch/stop') }}" class="btn btn-default btn-flat" id="switch">
|
||||||
document.getElementById('logout-form').submit();">
|
{{ trans('adminlte_lang::message.switchoff') }}
|
||||||
{{ trans('adminlte_lang::message.signout') }}
|
</a>
|
||||||
</a>
|
@else
|
||||||
|
<a href="{{ url('/logout') }}" class="btn btn-default btn-flat" id="logout"
|
||||||
|
onclick="event.preventDefault();
|
||||||
|
document.getElementById('logout-form').submit();">
|
||||||
|
{{ trans('adminlte_lang::message.signout') }}
|
||||||
|
</a>
|
||||||
|
|
||||||
<form id="logout-form" action="{{ url('/logout') }}" method="POST" style="display: none;">
|
<form id="logout-form" action="{{ url('/logout') }}" method="POST" style="display: none;">
|
||||||
{{ csrf_field() }}
|
{{ csrf_field() }}
|
||||||
<input type="submit" value="logout" style="display: none;">
|
<input type="submit" value="logout" style="display: none;">
|
||||||
</form>
|
</form>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -2,12 +2,13 @@
|
|||||||
|
|
||||||
namespace Leenooks\Controllers;
|
namespace Leenooks\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\User;
|
|
||||||
use Auth;
|
|
||||||
use Redirect;
|
use Redirect;
|
||||||
use Session;
|
use Session;
|
||||||
|
|
||||||
|
use App\User;
|
||||||
|
|
||||||
class AdminController extends Controller
|
class AdminController extends Controller
|
||||||
{
|
{
|
||||||
public function __construct()
|
public function __construct()
|
||||||
@ -15,12 +16,22 @@ class AdminController extends Controller
|
|||||||
$this->middleware('auth');
|
$this->middleware('auth');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function switch_authorised()
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function switch_session()
|
||||||
|
{
|
||||||
|
return ! Session::get('orig_user');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo Change the background color (or something) so we know we are switched
|
* @todo Change the background color (or something) so we know we are switched
|
||||||
*/
|
*/
|
||||||
public function user_switch_start($id)
|
public function user_switch_start($id)
|
||||||
{
|
{
|
||||||
if ($this->switch_authorised())
|
if ($this->switch_session() AND $this->switch_authorised())
|
||||||
{
|
{
|
||||||
$uo = User::find($id);
|
$uo = User::find($id);
|
||||||
|
|
||||||
@ -43,10 +54,4 @@ class AdminController extends Controller
|
|||||||
|
|
||||||
return Redirect::to('/home');
|
return Redirect::to('/home');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public function switch_authorised()
|
|
||||||
{
|
|
||||||
// @todo
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
16
src/Traits/UserSwitch.php
Normal file
16
src/Traits/UserSwitch.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if users have been switched
|
||||||
|
*/
|
||||||
|
namespace Leenooks\Traits;
|
||||||
|
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
trait UserSwitch
|
||||||
|
{
|
||||||
|
public function switched()
|
||||||
|
{
|
||||||
|
return Session::get('orig_user');
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user