Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

Commit

Permalink
🐛 FIX: Logout Issues
Browse files Browse the repository at this point in the history
Fix logout button URL and issue where session could persist after logout
RB-7 and RB-6
  • Loading branch information
taija committed Feb 12, 2020
1 parent 57b2f4e commit 8459986
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
10 changes: 5 additions & 5 deletions app/Http/Controllers/BlocksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class BlocksController extends Controller
{
//
public function blockList()
public function blockList(Request $request)
{
/**
* Load from Data API
Expand All @@ -24,14 +24,14 @@ public function blockList()
);

$user = $dataAPI->getUser(
session('username'),
$request->get('username'),
$token
);

$data = array(
'userData' => $user,
'username' => session('username'),
'logout' => session('logout_url'),
'username' => $request->get('username'),
'logout' => $request->get('logoutUrl'),
);

if (null !== $user && null !== $user['blocks'])
Expand All @@ -44,7 +44,7 @@ public function blockList()
}
else
{
Log::info( 'User '. (null !== session('username') ? session('username') : '[NOT SET]') .' logged in, had no student record');
Log::info( 'User '. (null !== $request->get('username') ? $request->get('username') : '[NOT SET]') .' logged in, had no student record');
return view('error/notStudent', $data);
}

Expand Down
11 changes: 6 additions & 5 deletions app/Http/Middleware/SimpleSAMLphp.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@ public function handle($request, Closure $next)
* Store Username and Auth Object in Session
*/
$attributes = $auth->getAttributes();
session(['username' => $attributes[config('simplesamlphp.username')][0]]);
session(['logout_url' => $auth->getLogoutURL('https://www.bellevuecollege.edu')]);
$request->attributes->add(['username' => $attributes[config('simplesamlphp.username')][0]]);
$request->attributes->add(['logoutUrl' => $auth->getLogoutURL('https://www.bellevuecollege.edu')]);

}
else // Disable auth on test and local environments
{
session(['username' => 't.test']); // Modify this username if needed
session(['logout_url' => 'https://www.bellevuecollege.edu']);
$request->attributes->add(['username' => 't.test']); // Modify this username if needed
$request->attributes->add(['logoutUrl' => 'https://www.bellevuecollege.edu']);
}

return $next($request);
}
}
}
4 changes: 2 additions & 2 deletions resources/views/error/notStudent.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

@section('content')
<div class="alert alert-warning">
<h1>This is not a student account</h1>
<p>Registration block information is only available for Bellevue College students. You have logged in with a non-student account. <a href="" class="btn btn-default">Log out</a></p>
<h1>Error: Unable to retrieve student account</h1>
<p>Registration block information is only available for Bellevue College students. You may have logged in with a non-student account, or an error has occurred. <a href="{{ $logout }}" class="btn btn-default">Log out</a></p>
</div>
@endsection

0 comments on commit 8459986

Please sign in to comment.