Support the ongoing development of Laravel.io →
posted 10 years ago
Eloquent
Last updated 2 years ago.
0

Why aren't you using the basic Auth filter ?

Last updated 2 years ago.
0

eriktisme said:

Why aren't you using the basic Auth filter ?

How? Do you mean like this?


Route::filter('login_check', function()
{
   
    if(!Auth::Admin())
    return Redirect::to('/');
   
});


I get this:

ErrorException

call_user_func_array() expects parameter 1 to be a valid callback, class 'Illuminate\Auth\Guard' does not have a method 'Admin'

Last updated 2 years ago.
0

Like you are doing with your login_check

function __construct() {
    // echo "Called";
    $this->beforeFilter('auth');
}
Last updated 2 years ago.
0

In filters.php, there's a filter that says:

Route::filter('auth', function()
{
    if (Auth::guest()) return Redirect::guest('login');
});

That will let through any person authenticated.

On the other hand, if you want to set up a filter that will only let through people that have not been authenticated, you can use the built in guest filter:

Route::filter('guest', function()
{
    if (Auth::check()) return Redirect::to('/');
});
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.