[英]How to show laravel login throttle message at the top of the page?
默认情况下,Laravel在电子邮件/用户名字段下方显示限制消息“太多登录尝试”消息。
如何在页面顶部显示此消息。
在您的LoginController中覆盖sendLockoutResponse
protected function sendLockoutResponse(Request $request)
{
$seconds = $this->limiter()->availableIn(
$this->throttleKey($request)
);
throw ValidationException::withMessages([
'throttle' => [Lang::get('auth.throttle', ['seconds' => $seconds])],
])->status(Response::HTTP_TOO_MANY_REQUESTS);
}
您需要导入以下内容
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Lang;
use Illuminate\Validation\ValidationException;
然后在您的视图中添加以下内容,在其中您需要限制消息
如果您的Laravel版本是5.8.12
或更高版本
@error('throttle')
<strong>{{ $message }}</strong>
@enderror
其他
@if ($errors->has('throttle'))
<strong>{{ $errors->first('throttle') }}</strong>
@endif
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.