1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-07-02 07:04:56 +08:00

!26 开放登录线上测试2

* 初步完成开放登录,待线上测试2
This commit is contained in:
koogua 2020-12-05 19:52:26 +08:00
parent a5fcbc92d8
commit ea7d4d648d
6 changed files with 36 additions and 35 deletions

View File

@ -13,8 +13,8 @@
<div class="layui-input-block"> <div class="layui-input-block">
<button id="submit-btn" class="layui-btn layui-btn-fluid" lay-submit="true" lay-filter="go">登录并绑定已有帐号</button> <button id="submit-btn" class="layui-btn layui-btn-fluid" lay-submit="true" lay-filter="go">登录并绑定已有帐号</button>
<input type="hidden" name="provider" value="{{ provider }}"> <input type="hidden" name="provider" value="{{ provider }}">
<input type="hidden" name="code" value="{{ request.get.code }}"> <input type="hidden" name="code" value="{{ request.get('code') }}">
<input type="hidden" name="state" value="{{ request.get.state }}"> <input type="hidden" name="state" value="{{ request.get('state') }}">
</div> </div>
</div> </div>
</form> </form>

View File

@ -21,8 +21,8 @@
<div class="layui-input-block"> <div class="layui-input-block">
<button id="cv-submit-btn" class="layui-btn layui-btn-fluid layui-btn-disabled" disabled="disabled" lay-submit="true" lay-filter="go">注册并绑定帐号</button> <button id="cv-submit-btn" class="layui-btn layui-btn-fluid layui-btn-disabled" disabled="disabled" lay-submit="true" lay-filter="go">注册并绑定帐号</button>
<input type="hidden" name="provider" value="{{ provider }}"> <input type="hidden" name="provider" value="{{ provider }}">
<input type="hidden" name="code" value="{{ request.get.code }}"> <input type="hidden" name="code" value="{{ request.get('code') }}">
<input type="hidden" name="state" value="{{ request.get.state }}"> <input type="hidden" name="state" value="{{ request.get('state') }}">
<input id="cv-app-id" type="hidden" value="{{ captcha.app_id }}"> <input id="cv-app-id" type="hidden" value="{{ captcha.app_id }}">
<input id="cv-ticket" type="hidden" name="ticket"> <input id="cv-ticket" type="hidden" name="ticket">
<input id="cv-rand" type="hidden" name="rand"> <input id="cv-rand" type="hidden" name="rand">

View File

@ -63,6 +63,7 @@
<div class="my-nav"> <div class="my-nav">
<span class="title">开放登录</span> <span class="title">开放登录</span>
</div> </div>
{% if connects %}
<div class="connect-tips">已经绑定的第三方帐号</div> <div class="connect-tips">已经绑定的第三方帐号</div>
<div class="connect-list"> <div class="connect-list">
<table class="layui-table"> <table class="layui-table">
@ -85,6 +86,7 @@
{% endfor %} {% endfor %}
</table> </table>
</div> </div>
{% endif %}
<div class="connect-tips">支持绑定的第三方帐号</div> <div class="connect-tips">支持绑定的第三方帐号</div>
<div class="oauth-list"> <div class="oauth-list">
<a class="layui-icon layui-icon-login-qq login-qq" href="{{ url({'for':'home.oauth.qq'}) }}"></a> <a class="layui-icon layui-icon-login-qq login-qq" href="{{ url({'for':'home.oauth.qq'}) }}"></a>

View File

@ -33,7 +33,6 @@ class QQ extends OAuth
'client_secret' => $this->clientSecret, 'client_secret' => $this->clientSecret,
'redirect_uri' => $this->redirectUri, 'redirect_uri' => $this->redirectUri,
'grant_type' => 'authorization_code', 'grant_type' => 'authorization_code',
'state' => 'ok',
]; ];
$response = $this->httpPost(self::ACCESS_TOKEN_URL, $params); $response = $this->httpPost(self::ACCESS_TOKEN_URL, $params);
@ -90,7 +89,7 @@ class QQ extends OAuth
} }
if (!isset($result['openid'])) { if (!isset($result['openid'])) {
throw new \Exception("Fetch Openid Failed:{$response}"); throw new \Exception("Fetch OpenId Failed:{$response}");
} }
return $result['openid']; return $result['openid'];
@ -100,8 +99,8 @@ class QQ extends OAuth
{ {
$data = json_decode($response, true); $data = json_decode($response, true);
if ($data['ret'] != 0) { if (isset($data['ret']) && $data['ret'] != 0) {
throw new \Exception("Fetch User Info Failed{$data['msg']}"); throw new \Exception("Fetch User Info Failed:{$response}");
} }
$userInfo['id'] = $this->openId; $userInfo['id'] = $this->openId;

View File

@ -8,7 +8,7 @@ class WeiBo extends OAuth
{ {
const AUTHORIZE_URL = 'https://api.weibo.com/oauth2/authorize'; const AUTHORIZE_URL = 'https://api.weibo.com/oauth2/authorize';
const ACCESS_TOKEN_URL = 'https://api.weibo.com/oauth2/oauth2/access_token'; const ACCESS_TOKEN_URL = 'https://api.weibo.com/oauth2/access_token';
const USER_INFO_URL = 'https://api.weibo.com/2/users/show.json'; const USER_INFO_URL = 'https://api.weibo.com/2/users/show.json';
public function getAuthorizeUrl() public function getAuthorizeUrl()
@ -61,7 +61,7 @@ class WeiBo extends OAuth
{ {
$data = json_decode($response, true); $data = json_decode($response, true);
if (!isset($data['access_token']) || isset($data['uid'])) { if (!isset($data['access_token']) || !isset($data['uid'])) {
throw new \Exception("Fetch Access Token Failed:{$response}"); throw new \Exception("Fetch Access Token Failed:{$response}");
} }
@ -74,8 +74,8 @@ class WeiBo extends OAuth
{ {
$data = json_decode($response, true); $data = json_decode($response, true);
if ($data['error_code'] != 0) { if (isset($data['error_code']) && $data['error_code'] != 0) {
throw new \Exception("Fetch User Info Failed:{$data['error']}"); throw new \Exception("Fetch User Info Failed:{$response}");
} }
$userInfo['id'] = $this->openId; $userInfo['id'] = $this->openId;

View File

@ -62,7 +62,7 @@ class WeiXin extends OAuth
$data = json_decode($response, true); $data = json_decode($response, true);
if (isset($data['errcode']) && $data['errcode'] != 0) { if (isset($data['errcode']) && $data['errcode'] != 0) {
throw new \Exception("Fetch Access Token Failed:{$data['errmsg']}"); throw new \Exception("Fetch Access Token Failed:{$response}");
} }
$this->openId = $data['openid']; $this->openId = $data['openid'];
@ -75,7 +75,7 @@ class WeiXin extends OAuth
$data = json_decode($response, true); $data = json_decode($response, true);
if (isset($data['errcode']) && $data['errcode'] != 0) { if (isset($data['errcode']) && $data['errcode'] != 0) {
throw new \Exception("Fetch User Info Failed:{$data['errmsg']}"); throw new \Exception("Fetch User Info Failed:{$response}");
} }
$userInfo['id'] = $this->openId; $userInfo['id'] = $this->openId;