nick8081

Results 2 comments of nick8081

@shangeyao 楼主解决了没。遇到相同的问题了,老板要求必须解决,苦啊。

> 参考:Dcat-admin实现一个账号只能同时在线一次,https://learnku.com/articles/56532 我用的larave库里的这个方法:https://learnku.com/docs/laravel/9.x/authentication/12239#33e248 但还要改一些地方: 1,在继承类 App\Admin\Controllers\AuthController里,覆写postLogin方法,登录成功时调用Auth::logoutOtherDevices(request("password")); 2,写个子类继承这个中间件 AuthenticateSession,把父类的handle方法代码抄过来,这个判断里增加auth/setting判断。 if ($request->session()->get('password_hash_'.$this->auth->getDefaultDriver()) !== $request->user()->getAuthPassword()) { if($request->path() !== 'auth/setting') { //增加这个判断,避免改密码把自己踢出登录状态 $this->logout($request); } } 3,Kernel.php中间件里web下面插入第2步的类。 "web" => [ ... \App\Admin\Middleware\AuthenticateSession::class, ... ], 4,config/auth.php...