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

张家港早晨网站制作百度店铺怎么入驻

张家港早晨网站制作,百度店铺怎么入驻,北京网站建设认知,广州番禺新楼盘最新房价在用户身份验证的情况下,Laravel 具有内置的身份验证系统。我们可以根据要求轻松修改它。身份验证中包含的功能之一是Throttling. 为什么我们需要throttling保护? 基本上,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. We'll 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. We'll 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.tj-hxxt.cn/news/84733.html

相关文章:

  • 湖北网站建设 鄂 icp运营培训班有用吗
  • 做海报挣钱的网站全球搜索引擎网站
  • 油气集输毕业设计代做网站阿里巴巴seo排名优化
  • 郑州微网站制作营销型网站制作
  • 长春做网站哪里好专门发广告的app
  • 襄阳手机网站建设网络营销的定义
  • php宠物用品公司网站源码360点睛实效平台推广
  • 第三方网站下载素材是怎么做百度seo建议
  • 国内哪个推广网站做的好宁德市蕉城区
  • 风科网免费网站友情链接举例
  • 如何自制一个网站搜索引擎营销seo
  • 北京漫步云端网站建设外贸独立站推广
  • 各大高校的校园网站建设软文是什么样子的
  • 网站备案掉了怎么办如何做推广推广技巧
  • 网站制作建站程序西安seo包年服务
  • 杭州软件定制开发网站做优化一开始怎么做
  • 社区居委会网站建设公司官网模板
  • 做外贸应该去什么网站整合营销策划方案模板
  • 美国人做的汉字网站网上推销产品去什么平台
  • 柳州网站建设源码网络推广外包公司哪家好
  • 沈阳手机网站建设专业seo站长工具
  • 淘宝做网站骗局活动策划方案详细模板
  • 智慧团建网站登陆平台镇江网站关键字优化
  • 网站建设如何快速增加用户哪个平台推广效果好
  • 哪个网站有上门做指甲php开源建站系统
  • 深圳市建网站公司外贸推广哪个公司好
  • 律师网站建设公司打开网址资料网站
  • 橙子建站的验证码安全吗女生读网络营销与电商直播
  • 武汉建网站的网站淘宝网店代运营正规公司
  • 全国人防工程建设管理培训班举行seo网站推广专员