我正在使用Laratrust包来管理authentification。
现在我尝试添加一个新的条件来进行身份验证。
用户应具有登录所需的status=1。
所以我使用了laratrust中定义的autheicate()函数,我只是添加了列status来验证身份验证。
所以我有以下代码:
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 '$'如果您对如何将条件状态添加到我的代码中有任何想法,请帮助我。
提前谢谢你。
发布于 2021-09-23 11:06:11
请在routeMiddleware阵列app/http/karnal.php的Karnal.php中添加状态中间件
protected $routeMiddleware = [
'status' =>\App\Http\Middleware\MiddlewareName::class // change MiddlewareName to your middleware name
]https://stackoverflow.com/questions/69283808
复制相似问题