0

I'm using the Laratrust package to manage the authentification.

Now I'm trying to adding a new condition to autheticate.

The user should have the status=1 to login.

So I'm using the function autheicate() defined in laratrust , I'm just adding the column status to verify the authentification.

So I have the following code :

 public function authenticate()
    {
        $this->ensureIsNotRateLimited();

        if (! Auth::attempt($this->only('email', 'password','status'->'1'), $this->boolean('remember'))) {
            RateLimiter::hit($this->throttleKey());

            throw ValidationException::withMessages([
                'email' => __('auth.failed'),
            ]);
        }

        RateLimiter::clear($this->throttleKey());
    }

But I'm getting the following error :

syntax error, unexpected ''1'' (T_CONSTANT_ENCAPSED_STRING), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$'

If you have any idea about how I can add the condition status to my code , help me.

Thank you in advance.

saadia
  • 79
  • 9
  • in more ideal way you can add a custom `middleware` to all your routes which which will alow only users whose `status =1` – JEJ Sep 22 '21 at 12:21
  • I did that `Route::group(['middleware' => ['auth','role:account_manager|admin|manager_de_filiale','status:1']], function() { Route::get('/dashboard', 'App\Http\Controllers\DashboardController@index')->name('dashboard'); });` But I get the following error : `Target class [status] does not exist.` – saadia Sep 22 '21 at 12:51

1 Answers1

0

Please Add Status Middleware In Karnal.php in routeMiddleware array app/http/karnal.php

protected $routeMiddleware = [
         'status' =>\App\Http\Middleware\MiddlewareName::class // change MiddlewareName to your middleware name 
     ]
KudosIntech
  • 504
  • 2
  • 10