0

我正在使用Laratrust包来管理authentification.

现在我正在尝试添加一个新条件来进行身份验证。

用户应该可以status=1登录。

所以我使用 laratrust 中定义的函数 autheicate() ,我只是添加列状态来验证身份验证。

所以我有以下代码:

 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());
    }

但我收到以下错误:

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

如果您对如何将条件状态添加到我的代码有任何想法,请帮助我。

先感谢您。

4

1 回答 1

0

请在 routeMiddleware 数组 app/http/karnal.php的 Karnal.php 中添加状态中间件

protected $routeMiddleware = [
         'status' =>\App\Http\Middleware\MiddlewareName::class // change MiddlewareName to your middleware name 
     ]
于 2021-09-23T11:06:10.517 回答