-
Notifications
You must be signed in to change notification settings - Fork 73
Usage
Zach :(){ :|: & } edited this page Oct 28, 2017
·
6 revisions
get('/auth/login', function(){
cas()->authenticate();
});
You would now have access to cas()->user()
, usually collected by middleware or custom authenticating guard.
public function handle($request, Closure $next)
{
if( ! cas()->checkAuthentication() )
{
if ($request->ajax()) {
return response('Unauthorized.', 401);
}
cas()->authenticate();
}
session()->put('cas_user', cas()->user() );
return $next($request);
}
You would now have access to the cas user via session or by cas()->user()
.
get('/auth/logout', [
'middleware' => 'cas.auth',
function(){
cas()->logout();
}
]);
Note: The cas.auth
middleware is optional, but you will need to handle the error when a user tries to logout when they do not have a cas session.