当前位置: 首页 > news >正文

优秀网站建设哪家专业上海网站建设网站开发

优秀网站建设哪家专业,上海网站建设网站开发,网站建设修饰商品,wordpress 首页文件在用户身份验证的情况下#xff0c;Laravel 具有内置的身份验证系统。我们可以根据要求轻松修改它。身份验证中包含的功能之一是Throttling. 为什么我们需要throttling保护#xff1f; 基本上#xff0c;throttling是用来保护暴力攻击的。它将在一定时间内检查登录尝试。在短… 在用户身份验证的情况下Laravel 具有内置的身份验证系统。我们可以根据要求轻松修改它。身份验证中包含的功能之一是Throttling. 为什么我们需要throttling保护 基本上throttling是用来保护暴力攻击的。它将在一定时间内检查登录尝试。在短登录中throttling会计算用户或机器人尝试失败的登录尝试次数。 使用自定义登录实现限制 默认情况下在内置身份验证控制器中实现限制。但是如果我们需要实现它到自定义登录呢 实现自定义登录限制非常容易。首先我们必须将ThrottlesLogins trait包含到您的控制器中。 use Illuminate\Foundation\Auth\ThrottlesLogins; 现在将此ThrottlesLogins trait 加到控制器中。 namespace App\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Foundation\Auth\ThrottlesLogins; class AuthController extends Controller { use ThrottlesLogins; ...... 现在转到用于对用户进行身份验证的方法。在我的例子中我使用了 login() POST 方法。并粘贴以下代码: public function login(Request $request) { // Authenticate Inputs $request-validate([ username required, password required|min:6|max:18 ]); // If the class is using the ThrottlesLogins trait, we can automatically throttle // the login attempts for this application. Well key this by the username and // the IP address of the client making these requests into this application. if (method_exists($this, hasTooManyLoginAttempts) $this-hasTooManyLoginAttempts($request)) { $this-fireLockoutEvent($request); return $this-sendLockoutResponse($request); } ....... 首先我们验证了用户提交的输入然后实现了hasTooManyLoginAttempts() 方法。此方法将检查用户在某个时间是否执行过一定数量的失败尝试然后系统将通过sendLockoutResponse()  方法阻止该用户。 现在我们必须通过incrementLoginAttempts()方法指示对ThrottlesLogins trait的失败登录尝试。 if( Auth::attempt([username $username, password $password]) ){ // Redirect to appropriate dashboard } else { // If the login attempt was unsuccessful we will increment the number of attempts // to login and redirect the user back to the login form. Of course, when this // user surpasses their maximum number of attempts they will get locked out. $this-incrementLoginAttempts($request); return redirect()-back() -withInput($request-all()) -withErrors([error Please check your username / password.]); } 您还可以通过$maxAttempts和$decayMinutes属性更改允许的最大尝试次数和限制的分钟数。在这里您可以找到完整的代码。 namespace App\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Foundation\Auth\ThrottlesLogins; class AuthController extends Controller { use ThrottlesLogins; /** * The maximum number of attempts to allow. * * return int */ protected $maxAttempts 5; /** * The number of minutes to throttle for. * * return int */ protected $decayMinutes 1; public function login(Request $request) { // Authenticate Inputs $request-validate([ username required, password required|min:6|max:18 ]); // If the class is using the ThrottlesLogins trait, we can automatically throttle // the login attempts for this application. Well key this by the username and // the IP address of the client making these requests into this application. if (method_exists($this, hasTooManyLoginAttempts) $this-hasTooManyLoginAttempts($request)) { $this-fireLockoutEvent($request); return $this-sendLockoutResponse($request); } $username $request-username; $password $request-password; if( Auth::attempt([username $username, password $password]) ){ // Redirect to appropriate dashboard } else { // If the login attempt was unsuccessful we will increment the number of attempts // to login and redirect the user back to the login form. Of course, when this // user surpasses their maximum number of attempts they will get locked out. $this-incrementLoginAttempts($request); return redirect()-back() -withInput($request-all()) -withErrors([error Please check your username / password.]); } } } Related Posts: 总结 到此这篇关于Laravel登录失败次数限制的文章就介绍到这了,更多相关Laravel登录失败次数限制内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家
http://www.hkea.cn/news/14264217/

相关文章:

  • 网站建设运营法律风险防范修改备案网站信息
  • 广州网站运营广州市做网站公司
  • 成立中英文网站建设工作领导小组wordpress登录美化
  • 优设设计师网站网站页面头部设计说明
  • 建立一个公司的网站吗合肥序曲网站建设公司怎么样
  • 保健品网站模板网站降权后 换域名
  • 最大的网站建设公司专业的龙岗网站建设
  • 有哪些网站可以免费做推广优化大师免安装版
  • 英文网站建设图片免费微信h5页面制作
  • 加强网站网络安全建设大连旅游网站建设大概多钱
  • 电商平台网站开发过程企业网址搭建
  • 万站群cms电商平台app大全
  • 中国旅游网站模板硬件开发有哪些方向
  • 宁波网站建设ysdshwordpress 4
  • 广源建设集团网站官网设计多少钱
  • 一起作做业网站wordpress相册投票插件
  • 青岛网站设计公司电话上杭县建设局网站
  • 有什么做衣服的网站吗支付网站设计
  • 建网站比较好wordpress app页面模板
  • 网站开发设计图片wordpress双栏主题开源
  • 信誉好的武进网站建设重庆做网站 哪个好些嘛
  • 云主机 小型网站superstore wordpress下载
  • 优化网站建设价格正能量不良网站免费软件下载
  • 公司企业网站建设的建站流程解析网站设计模版免费建站
  • 做网站现在要多少钱怎么去做网络推广
  • 求职网站网页模板下载网络游戏名字
  • 网站建设建站网易互客有什么做论文的网站
  • 深圳网站建设 工作室钓鱼网站怎么做
  • 海宏集团网站建设方案电子商务网站建设方面的论文
  • linux 做网站数据库网站的图片大小规定