所以我试图阻止已经登录的用户在不同的浏览器或另一台计算机上登录。我想我需要添加一个 IP 地址限制,但我不确定这会如何工作。
这是我的create_users_table.php迁移文件
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('username')->unique();
$table->string('email')->unique();
$table->string('password');
$table->timestamp('last_login');
$table->boolean('isActive')->default(true);
$table->rememberToken();
$table->timestamps();
});
Run Code Online (Sandbox Code Playgroud)
我还认为我需要在RedirectIfAuthenticated Middleware 类中创建一个限制。
所以,这是我的RedirectIfAuthenticated.php 类
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect('/');
}
return $next($request);
}
Run Code Online (Sandbox Code Playgroud)
什么是最佳解决方案,并防止已经登录的用户从另一台计算机登录?提前致谢 !!!