Skip to content

Commit b1d32a6

Browse files
committed
feat: add after_permission_denied and after_group_denied
1 parent 0cd5f3f commit b1d32a6

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

src/Config/Auth.php

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,12 @@ class Auth extends BaseConfig
6565
* to apply any logic you may need.
6666
*/
6767
public array $redirects = [
68-
'register' => '/',
69-
'login' => '/',
70-
'logout' => 'login',
71-
'force_reset' => '/',
68+
'register' => '/',
69+
'login' => '/',
70+
'logout' => 'login',
71+
'force_reset' => '/',
72+
'after_permission_denied' => '/',
73+
'after_group_denied' => '/',
7274
];
7375

7476
/**
@@ -475,6 +477,28 @@ public function forcePasswordResetRedirect(): string
475477
return $this->getUrl($url);
476478
}
477479

480+
/**
481+
* Returns the URL the user should be redirected to
482+
* if permission denied.
483+
*/
484+
public function afterPermissionDeniedRedirect(): string
485+
{
486+
$url = setting('Auth.redirects')['after_permission_denied'];
487+
488+
return $this->getUrl($url);
489+
}
490+
491+
/**
492+
* Returns the URL the user should be redirected to
493+
* if group denied.
494+
*/
495+
public function afterGroupDeniedRedirect(): string
496+
{
497+
$url = setting('Auth.redirects')['after_group_denied'];
498+
499+
return $this->getUrl($url);
500+
}
501+
478502
/**
479503
* Accepts a string which can be an absolute URL or
480504
* a named route or just a URI path, and returns the

0 commit comments

Comments
 (0)