-
-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-work the filters & Set the route name for routing in config (#444)
* Update LoginFilter.php * Update LoginFilter.php * Update LoginFilter.php use `uri_string()` to get the string from current url * uri_string is a bad idea I use `current_url()` and at line 51 I add an extra script in case if user use index.php :) * Update LoginFilter.php * use url_is() function for better solution NOTE : Since url_is() is available start from CodeIgniter 4.0.5, user must update their application. * a little re work for another filters I remove the helper('auth) since it's no use in there (performance reason) and put the session check at the begin of code, because we need a session data right? * fix * Update PermissionFilter.php * Candidate for BaseFilter & the reserved routes I add defaultLandingRoute to store the default route name after user success to login (depend on the real case) or fail in Permission & Role Filters too * Candidate for the new Filters * Update BaseFilter.php * extend the BaseFilter sorry my mistake * rename $defaultLandingRoute to $landingRoute * just rename some strings * Run CodeIgniter4 Coding Standards * Update Routes.php The Routes.php now will use reserved routing from Auth.php * Fix typo * Apply analysis fixes Co-authored-by: MGatner <mgatner@icloud.com>
- Loading branch information
1 parent
1d1f074
commit 100822e
Showing
6 changed files
with
134 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace Myth\Auth\Filters; | ||
|
||
use Myth\Auth\Config\Auth as AuthConfig; | ||
|
||
abstract class BaseFilter | ||
{ | ||
/** | ||
* Landing Route | ||
*/ | ||
protected $landingRoute; | ||
|
||
/** | ||
* Reserved Routes | ||
*/ | ||
protected $reservedRoutes; | ||
|
||
/** | ||
* Authenticate | ||
*/ | ||
protected $authenticate; | ||
|
||
/** | ||
* Authorize | ||
*/ | ||
protected $authorize; | ||
|
||
/** | ||
* Constructor | ||
*/ | ||
public function __construct() | ||
{ | ||
// Load the Auth config, for constructor only!!! | ||
$config = config(AuthConfig::class); | ||
|
||
// Load the routes | ||
$this->landingRoute = $config->landingRoute; | ||
$this->reservedRoutes = $config->reservedRoutes; | ||
|
||
// Load the authenticate service | ||
$this->authenticate = service('authentication'); | ||
|
||
// Load the authorize service | ||
$this->authorize = service('authorization'); | ||
|
||
// Load the helper | ||
if (! function_exists('logged_in')) { | ||
helper('auth'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters