Skip to content

Commit

Permalink
Fix deprecation
Browse files Browse the repository at this point in the history
Replace deprecated dispatchNow with dispatchSync. Thanks @will-dive for this catch.

Signed-off-by: Jesse Vista <[email protected]>
  • Loading branch information
upwebdesign committed May 9, 2023
1 parent 7151ba7 commit b69efd4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/Http/Controllers/LogoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace CodeGreenCreative\SamlIdp\Http\Controllers;

use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use CodeGreenCreative\SamlIdp\Jobs\SamlSlo;
use Illuminate\Http\Request;
use Illuminate\Support\Str;

class LogoutController extends Controller
{
Expand All @@ -29,10 +29,10 @@ public function index(Request $request)
// Loop through our service providers and "touch" the logout URL's
foreach (config('samlidp.sp') as $key => $sp) {
// Check if the service provider supports SLO
if (! empty($sp['logout']) && ! in_array($key, $request->session()->get('saml.slo', []))) {
if (!empty($sp['logout']) && !in_array($key, $request->session()->get('saml.slo', []))) {
// Push this SP onto the saml slo array
$request->session()->push('saml.slo', $key);
return redirect(SamlSlo::dispatchNow($sp));
return redirect(SamlSlo::dispatchSync($sp));
}
}

Expand Down
11 changes: 8 additions & 3 deletions src/Listeners/SamlAuthenticated.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace CodeGreenCreative\SamlIdp\Listeners;

use CodeGreenCreative\SamlIdp\Jobs\SamlSso;
use Illuminate\Auth\Events\Authenticated;
use CodeGreenCreative\SamlIdp\Jobs\SamlSso;

class SamlAuthenticated
{
Expand All @@ -15,8 +15,13 @@ class SamlAuthenticated
*/
public function handle(Authenticated $event)
{
if (in_array($event->guard, config('samlidp.guards')) && request()->filled('SAMLRequest') && ! request()->is('saml/logout') && request()->isMethod('get')) {
abort(response(SamlSso::dispatchNow($event->guard)), 302);
if (
in_array($event->guard, config('samlidp.guards')) &&
request()->filled('SAMLRequest') &&
!request()->is('saml/logout') &&
request()->isMethod('get')
) {
abort(response(SamlSso::dispatchSync($event->guard)), 302);
}
}
}
10 changes: 7 additions & 3 deletions src/Listeners/SamlLogin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace CodeGreenCreative\SamlIdp\Listeners;

use CodeGreenCreative\SamlIdp\Jobs\SamlSso;
use Illuminate\Auth\Events\Login;
use CodeGreenCreative\SamlIdp\Jobs\SamlSso;

class SamlLogin
{
Expand All @@ -15,8 +15,12 @@ class SamlLogin
*/
public function handle(Login $event)
{
if (in_array($event->guard, config('samlidp.guards')) && request()->filled('SAMLRequest') && ! request()->is('saml/logout')) {
abort(response(SamlSso::dispatchNow($event->guard)), 302);
if (
in_array($event->guard, config('samlidp.guards')) &&
request()->filled('SAMLRequest') &&
!request()->is('saml/logout')
) {
abort(response(SamlSso::dispatchSync($event->guard)), 302);
}
}
}

0 comments on commit b69efd4

Please sign in to comment.