修改 jetstream laravel/fortify 登录逻辑
论坛朋友问 Laravel脚手架jetstream:livewire 登陆逻辑在哪里修改? 早上没啥事,看了下代码,为了让 Jetsteam使用者 比较容易搜索到,把回答改成博文
一般是有触发Event 事件,直接添加对应的事件处理就好了。
或者像laravel-admin/dcat-admin
config有直接配置的文件
fortify早就为你想好了,需要修改登录逻辑, 它是通过配置的文件继承修改的
在你的配置文件中添加配置
config('fortify.pipelines.login')
[
config('fortify.limiters.login') ? null : EnsureLoginIsNotThrottled::class,
RedirectIfTwoFactorAuthenticatable::class,
AttemptToAuthenticate::class,
PrepareAuthenticatedSession::class,
]
格式如上
注意AttemptToAuthenticate::class
自己在自己的目录创建的,并且继承它(extends)
覆盖
/**
* Handle the incoming request.
*
* @param \Illuminate\Http\Request $request
* @param callable $next
* @return mixed
*/
public function handle($request, $next)
{
if (Fortify::$authenticateUsingCallback) {
return $this->handleUsingCustomCallback($request, $next);
}
if ($this->guard->attempt(
$request->only(Fortify::username(), 'password'),
$request->filled('remember'))
) {
return $next($request);
}
$this->throwFailedAuthenticationException($request);
}
在上面的方法了就可以 获取 $this->guard
,你可以写自己的业务了
实现视频连接: B站
本作品采用《CC 协议》,转载必须注明作者和本文链接
推荐文章: