Skip to content

Commit f10e633

Browse files
author
Ramon
committed
feat: Register and trigger custom wp_action upon token failure
1 parent 143030a commit f10e633

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Actions/Authentication.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ final class Authentication extends Base
4141

4242
'login_form_logout' => 'onLogout',
4343
'auth0_logout' => 'onLogout',
44+
'auth0_token_exchange_failed' => 'onExchangeFailed',
4445

4546
'before_signup_header' => 'onRegistration',
4647

@@ -495,8 +496,8 @@ public function onLogin(): void
495496
} catch (Throwable) {
496497
}
497498

498-
wp_redirect('/');
499-
exit;
499+
do_action('auth0_token_exchange_failed', $throwable);
500+
return;
500501
}
501502

502503
$session = $this->getSdk()
@@ -549,6 +550,13 @@ public function onLogin(): void
549550
exit;
550551
}
551552

553+
public function onExchangeFailed(Throwable $_)
554+
{
555+
// Custom hook ('auth0_token_exchange_failed') to register when token exchange fails.
556+
wp_redirect('/');
557+
exit;
558+
}
559+
552560
public function onLogout(): never
553561
{
554562
wp_logout();

0 commit comments

Comments
 (0)