Skip to content

Commit

Permalink
middleware fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lahirulhr committed Jan 25, 2022
1 parent 21e15c3 commit b209fd9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion resources/views/auth-switch.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<a href="{{ route('login-as',$key) }}">
<div class="as-block">
@if(auth()->check() && auth()->user()>email == $u['username'])
@if(auth()->check() && auth()->user()[config('auth-switch.username_column')] == $u['username'])
<div class="as-online"></div>@endif
{{ $u['name'] }}
<p>{{ $u['username'] }}</p>
Expand Down Expand Up @@ -63,6 +63,7 @@
bottom: 0;
z-index: 99999;
border: none;
margin: 12px;
}
/* The Modal (background) */
Expand Down
3 changes: 2 additions & 1 deletion src/SwitchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] ?? '/');
}
Expand Down

0 comments on commit b209fd9

Please sign in to comment.