diff --git a/resources/views/auth-switch.blade.php b/resources/views/auth-switch.blade.php index 2ac698a..188f2c8 100644 --- a/resources/views/auth-switch.blade.php +++ b/resources/views/auth-switch.blade.php @@ -12,7 +12,7 @@
- @if(auth()->check() && auth()->user()>email == $u['username']) + @if(auth()->check() && auth()->user()[config('auth-switch.username_column')] == $u['username'])
@endif {{ $u['name'] }}

{{ $u['username'] }}

@@ -63,6 +63,7 @@ bottom: 0; z-index: 99999; border: none; + margin: 12px; } /* The Modal (background) */ diff --git a/src/SwitchController.php b/src/SwitchController.php index be2041e..2d19be2 100644 --- a/src/SwitchController.php +++ b/src/SwitchController.php @@ -10,13 +10,14 @@ class SwitchController extends Controller { public function __invoke($key) { - + $model = config('auth-switch.model'); $model = new $model(); $users = config('auth-switch.accounts', []); $u = $model::where(config('auth-switch.username_column', 'email'), $users[$key]['username'])->first(); if ($u) { + Auth::logout(); Auth::login($u); return redirect()->to($users[$key]['redirect_to'] ?? '/'); }