Aaron-wlh

1665 经验值

我也感觉不能,不过没有尝试过。。另外有个问题,还是多用户认证,auth:user和auth:admin这两个中间件,如果用户没有登陆应该跳转的是两个不同的登陆页面,这个应该是如何设置呢?是在Exceptions/Handler.php里面进行判断是哪种guard 然后根据不同的guard跳转到不同的登陆页面吗?

如果是多用户认证登陆的话,比如前台使用的guard是user 后台使用的是admin,那么在api.php文件中使用Auth::guard(api)->user() 是否能分辨出是前台登陆用户还是后台登陆用户调用的接口? 我这么说不知道你名不明白我的意思==

在你的评论前面其实已经有人提出了这个问题,你可以去看看的

我还是不明白,password::broker()的broker()方法跟Illuminate\Auth\Passwords\PasswordBrokerManager 的 broker 方法是怎么挂钩的,看了很久也没弄懂,懵逼~

public function broker()
    {
        return Password::broker();
    }

我想知道password::broker()的 broker()方法写在哪里,Illuminate\Support\Facades\Password这个类中没有此方法,它继承的类中也没有呀。

我在laravel的eloquent中定义了 protected $casts = ['identity' => 'array']; ,然后在数据库中发现identity字段的中文成了 ["\u515a\u5c0f\u7ec4\u957f","\u7f51\u683c\u957f","\u5c45\u6c11\u4ee3\u8868","\u8bae\u4e8b\u4f1a\u6210\u5458"] ,有没有办法存到数据库中的时候就是 ["党小组长", "网格长", "居民代表", "议事会成员"] 这样的?

每次暂停一段时间,然后视频就不能看了。 还有能不能加上个 下一节视频的链接,原来都有的。

我的代码:

public function oauth(Request $request)
    {
        $http = new Client();
        $response = $http->post('http://dev.laravist-5.com/oauth/token', [
            'form_params' => [
                'grant_type' => 'authorization_code',
                'client_id' => 4,
                'client_secret' => 'SUcUUlPSGK30FsiouMenQUieZpLjKQiurjEloXPL',
                'redirect_uri' => 'http://dev.passport-client.com/callback',
                'code' => $request->get('code'),
            ]
        ]);
        return json_decode((string) $response->getBody(), true);

    }

报的错误:

ServerException in RequestException.php line 113:
Server error: `POST http://dev.laravist-5.com/oauth/token` resulted in a `500 Internal Server Error` response:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="robots" content="noindex,nofollow (truncated...)

我试过这种:

 public function oauth(Request $request)
    {
        $post_data = [
            'grant_type' => 'authorization_code',
            'client_id' => 4,
            'client_secret' => 'SUcUUlPSGK30FsiouMenQUieZpLjKQiurjEloXPL',
            'redirect_uri' => 'http://dev.passport-client.com/callback',
            'code' => $request->get('code'),
        ];
        //http://dev.laravist-5.com/oauth/token
        $result = json_decode($this->curl('http://dev.laravist-5.com/oauth/token', 'POST', $post_data), true);
        dd($result);
        return json_decode((string) $result->getBody(), true);
    }


    private function curl($url, $method = 'GET', $data = [])
    {
        $handler = curl_init();
        curl_setopt($handler, CURLOPT_URL, $url);
        curl_setopt($handler, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($handler, CURLOPT_HEADER, 0);
        if ($method == 'POST') {
            curl_setopt($handler, CURLOPT_POST, 1);
            curl_setopt($handler, CURLOPT_POSTFIELDS, $data);
        }
        $output = curl_exec($handler);
        curl_close($handler);
        return $output;
    }

结果是: null
不清楚这个报错是什么意思呢,我究竟哪里出了问题?

安装passport出现:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: remove laravel/framework v5.3.31
    - Conclusion: don't install laravel/framework v5.3.31
    - laravel/passport v2.0.0 requires illuminate/support ~5.4 -> satisfiable by illuminate/support[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.9].
    - laravel/passport v2.0.1 requires illuminate/support ~5.4 -> satisfiable by illuminate/support[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.9].
    - laravel/passport v2.0.10 requires illuminate/support ~5.4 -> satisfiable by illuminate/support[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.9].
    - laravel/passport v2.0.11 requires illuminate/support ~5.4 -> satisfiable by illuminate/support[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.9].
    - laravel/passport v2.0.2 requires illuminate/support ~5.4 -> satisfiable by illuminate/support[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.9].
    - laravel/passport v2.0.3 requires illuminate/support ~5.4 -> satisfiable by illuminate/support[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.9].
    - laravel/passport v2.0.4 requires illuminate/support ~5.4 -> satisfiable by illuminate/support[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.9].
    - laravel/passport v2.0.5 requires illuminate/support ~5.4 -> satisfiable by illuminate/support[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.9].
    - laravel/passport v2.0.6 requires illuminate/support ~5.4 -> satisfiable by illuminate/support[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.9].
    - laravel/passport v2.0.7 requires illuminate/support ~5.4 -> satisfiable by illuminate/support[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.9].
    - laravel/passport v2.0.8 requires illuminate/support ~5.4 -> satisfiable by illuminate/support[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.9].
    - laravel/passport v2.0.9 requires illuminate/support ~5.4 -> satisfiable by illuminate/support[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.9].
    - don't install illuminate/support v5.4.0|don't install laravel/framework v5.3.31
    - don't install illuminate/support v5.4.13|don't install laravel/framework v5.3.31
    - don't install illuminate/support v5.4.17|don't install laravel/framework v5.3.31
    - don't install illuminate/support v5.4.19|don't install laravel/framework v5.3.31
    - don't install illuminate/support v5.4.27|don't install laravel/framework v5.3.31
    - don't install illuminate/support v5.4.9|don't install laravel/framework v5.3.31
    - Installation request for laravel/framework (locked at v5.3.31, required as 5.3.*) -> satisfiable by laravel/framework[v5.3.31].
    - Installation request for laravel/passport ^2.0 -> satisfiable by laravel/passport[v2.0.0, v2.0.1, v2.0.10, v2.0.11, v2.0.2, v2.0.3, v2.0.4, v2.0.5, v2.0.6, v2.0.7, v2.0.8, v2.0.9].


Installation failed, reverting ./composer.json to its original content.

是什么原因呢?