Adding condition status =1 to laratrust authetification using Laravel8

193 views Asked by At

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.

1

There are 1 answers

0
KudosIntech On

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 
     ]