Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel认证模型更改_Php_Laravel_Jwt - Fatal编程技术网

Php Laravel认证模型更改

Php Laravel认证模型更改,php,laravel,jwt,Php,Laravel,Jwt,我有两个用于admin和client的表,每种类型的用户有两种不同的登录方法。 我已经对admin使用了trument()方法。我正在尝试为客户端创建JWT身份验证。此时,当我尝试验证客户端登录时,laravel在admin表内查询,而我希望它在client表内查询。我试图设置config来专门研究客户机模型。但它仍在调查管理 当客户端尝试登录时,如何告诉laravel避免查看管理表 if($dbPass==$password) { //find secret a

我有两个用于admin和client的表,每种类型的用户有两种不同的登录方法。 我已经对admin使用了trument()方法。我正在尝试为客户端创建JWT身份验证。此时,当我尝试验证客户端登录时,laravel在admin表内查询,而我希望它在client表内查询。我试图设置config来专门研究客户机模型。但它仍在调查管理

当客户端尝试登录时,如何告诉laravel避免查看管理表

    if($dbPass==$password)
    {
        //find secret api key and send it to curl
        //$this->callTeamworkApi($query->secretApiKey);
        //set session
    //JWT authenticate
     //$credentials = ["email"=>$email,"password"=>$password];
        //$credentials = $request->all('email','password');
        $credentials =[];
        $credentials['email'] = $email;
        $credentials['password'] = $request->password;

        try{
             \Config::set('auth.model', 'Client');
             \Config::set( 'auth.table' , 'clients' );
             if( ! $token = JWTAuth::attempt($credentials))
              {
                return response()->json([
                    'response' => 'Some error with user credentials' 
                ]);
              }else{
                // $request->session()->put('secretApiKey', $query->secretApiKey);
                // $request->session()->put('userEmail', $sessionEmail);
                // $request->session()->put('userId', $sessionId);
                // $request->session()->put('userName', $sessionName);
                // $request->session()->put('timeCreated', $timeCreated);
                //find user details and put them inside session array
                $msg = "Login_checked";
                return response()->json(["token"=>compact('token'), "msg"=> $msg]);
            }

        }catch(JWTExceptions $err){
            return response()->json(['response'=>$err]);
        }

    }else{
        $msg = "Password_wrong";
    }

所有身份验证驱动程序都有一个用户提供程序。这定义了如何从数据库或此应用程序用于持久化用户数据的其他存储机制中检索用户

如果有多个用户表或模型,则应配置多个用户表或模型 表示每个模型/表格的源

这应该在
config/auth.php
文件中完成

'providers' => [

    'admins' => [
        'driver' => 'eloquent',
        'model' => App\Admin::class,
    ],
   'clients' => [
        'driver' => 'eloquent',
        'model' => App\Client::class,
    ],

],

这在Laravel 5中有效,我不确定版本4和更低版本。

所有身份验证驱动程序都有一个用户提供程序。这定义了如何从数据库或此应用程序用于持久化用户数据的其他存储机制中检索用户

如果有多个用户表或模型,则应配置多个用户表或模型 表示每个模型/表格的源

这应该在
config/auth.php
文件中完成

'providers' => [

    'admins' => [
        'driver' => 'eloquent',
        'model' => App\Admin::class,
    ],
   'clients' => [
        'driver' => 'eloquent',
        'model' => App\Client::class,
    ],

],
这在Laravel5中有效,我不确定版本4和更低版本