diff --git a/resources/themes/adminlte/lang/en/message.php b/resources/themes/adminlte/lang/en/message.php index 5defedf..fa6276e 100644 --- a/resources/themes/adminlte/lang/en/message.php +++ b/resources/themes/adminlte/lang/en/message.php @@ -136,4 +136,5 @@ return [ 'loggedin' => 'Logged in!', 'entering' => 'Entering...', 'registered' => 'User Registered!', + 'switchoff' => 'Switch Back', ]; diff --git a/resources/themes/adminlte/views/auth/register.blade.php b/resources/themes/adminlte/views/auth/register.blade.php index 088ddf0..eefe88f 100644 --- a/resources/themes/adminlte/views/auth/register.blade.php +++ b/resources/themes/adminlte/views/auth/register.blade.php @@ -10,7 +10,7 @@
@if (count($errors) > 0) diff --git a/resources/themes/adminlte/views/layouts/partials/mainheader.blade.php b/resources/themes/adminlte/views/layouts/partials/mainheader.blade.php index 58b6220..7574731 100644 --- a/resources/themes/adminlte/views/layouts/partials/mainheader.blade.php +++ b/resources/themes/adminlte/views/layouts/partials/mainheader.blade.php @@ -45,7 +45,7 @@ @include('adminlte::layouts.partials.topmenu') -
- - {{ trans('adminlte_lang::message.signout') }} - + @if ($user->switched()) + + {{ trans('adminlte_lang::message.switchoff') }} + + @else + + {{ trans('adminlte_lang::message.signout') }} + - + + @endif
diff --git a/src/Controllers/AdminController.php b/src/Controllers/AdminController.php index 49b1f0e..6dae1d4 100644 --- a/src/Controllers/AdminController.php +++ b/src/Controllers/AdminController.php @@ -2,12 +2,13 @@ namespace Leenooks\Controllers; +use Illuminate\Support\Facades\Auth; use App\Http\Controllers\Controller; -use App\User; -use Auth; use Redirect; use Session; +use App\User; + class AdminController extends Controller { public function __construct() @@ -15,12 +16,22 @@ class AdminController extends Controller $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 */ public function user_switch_start($id) { - if ($this->switch_authorised()) + if ($this->switch_session() AND $this->switch_authorised()) { $uo = User::find($id); @@ -43,10 +54,4 @@ class AdminController extends Controller return Redirect::to('/home'); } - - public function switch_authorised() - { - // @todo - return TRUE; - } -} +} \ No newline at end of file diff --git a/src/Traits/UserSwitch.php b/src/Traits/UserSwitch.php new file mode 100644 index 0000000..a760421 --- /dev/null +++ b/src/Traits/UserSwitch.php @@ -0,0 +1,16 @@ +