Skip to content

Creating Group Filters #483

Answered by lonnieezell
MarcPinnell asked this question in Q&A
Discussion options

You must be logged in to vote

It's probably easiest to create 2 new filters - one for Portal and one for Admin. You can look at the existing SessionAuth filter and make the checks to be as specific as you want. You would use the SessionAuth filter for all of your protected routes, and then additionally use the new custom filters. So something like this for the filter:

public function before(RequestInterface $request, $arguments = null)
{
    $user = auth()->user();

    // do your checks here
    if ($user->inGroup('staff', 'admin')) {
        return;
    }

    return redirect()->route('login');
}

Then in app/Config/Filters.php:

public $aliases = [
    ...
    'admin' => My\Admin\Filter::class,
    'portal' => My\Portal

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@MarcPinnell
Comment options

Answer selected by MarcPinnell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants