1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-07-01 22:54: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">
<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="code" value="{{ request.get.code }}">
<input type="hidden" name="state" value="{{ request.get.state }}">
<input type="hidden" name="code" value="{{ request.get('code') }}">
<input type="hidden" name="state" value="{{ request.get('state') }}">
</div>
</div>
</form>

View File

@ -21,8 +21,8 @@
<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>
<input type="hidden" name="provider" value="{{ provider }}">
<input type="hidden" name="code" value="{{ request.get.code }}">
<input type="hidden" name="state" value="{{ request.get.state }}">
<input type="hidden" name="code" value="{{ request.get('code') }}">
<input type="hidden" name="state" value="{{ request.get('state') }}">
<input id="cv-app-id" type="hidden" value="{{ captcha.app_id }}">
<input id="cv-ticket" type="hidden" name="ticket">
<input id="cv-rand" type="hidden" name="rand">

View File

@ -63,28 +63,30 @@
<div class="my-nav">
<span class="title">开放登录</span>
</div>
<div class="connect-tips">已经绑定的第三方帐号</div>
<div class="connect-list">
<table class="layui-table">
<tr>
<td>序号</td>
<td>提供方</td>
<td>用户信息</td>
<td>创建日期</td>
<td width="15%">操作</td>
</tr>
{% for connect in connects %}
{% set url = url({'for':'home.uc.unconnect','id':connect.id}) %}
{% if connects %}
<div class="connect-tips">已经绑定的第三方帐号</div>
<div class="connect-list">
<table class="layui-table">
<tr>
<td>{{ loop.index }}</td>
<td>{{ connect_provider(connect) }}</td>
<td>{{ connect_user(connect) }}</td>
<td>{{ date('Y-m-d H:i',connect.create_time) }}</td>
<td><a class="layui-btn layui-btn-danger layui-btn-sm kg-delete" href="javascript:" data-url="{{ url }}" data-tips="确定要解除绑定吗?">解除绑定</a></td>
<td>序号</td>
<td>提供方</td>
<td>用户信息</td>
<td>创建日期</td>
<td width="15%">操作</td>
</tr>
{% endfor %}
</table>
</div>
{% for connect in connects %}
{% set url = url({'for':'home.uc.unconnect','id':connect.id}) %}
<tr>
<td>{{ loop.index }}</td>
<td>{{ connect_provider(connect) }}</td>
<td>{{ connect_user(connect) }}</td>
<td>{{ date('Y-m-d H:i',connect.create_time) }}</td>
<td><a class="layui-btn layui-btn-danger layui-btn-sm kg-delete" href="javascript:" data-url="{{ url }}" data-tips="确定要解除绑定吗?">解除绑定</a></td>
</tr>
{% endfor %}
</table>
</div>
{% endif %}
<div class="connect-tips">支持绑定的第三方帐号</div>
<div class="oauth-list">
<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,
'redirect_uri' => $this->redirectUri,
'grant_type' => 'authorization_code',
'state' => 'ok',
];
$response = $this->httpPost(self::ACCESS_TOKEN_URL, $params);
@ -90,7 +89,7 @@ class QQ extends OAuth
}
if (!isset($result['openid'])) {
throw new \Exception("Fetch Openid Failed:{$response}");
throw new \Exception("Fetch OpenId Failed:{$response}");
}
return $result['openid'];
@ -100,8 +99,8 @@ class QQ extends OAuth
{
$data = json_decode($response, true);
if ($data['ret'] != 0) {
throw new \Exception("Fetch User Info Failed{$data['msg']}");
if (isset($data['ret']) && $data['ret'] != 0) {
throw new \Exception("Fetch User Info Failed:{$response}");
}
$userInfo['id'] = $this->openId;

View File

@ -8,7 +8,7 @@ class WeiBo extends OAuth
{
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';
public function getAuthorizeUrl()
@ -60,8 +60,8 @@ class WeiBo extends OAuth
private function parseAccessToken($response)
{
$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}");
}
@ -74,8 +74,8 @@ class WeiBo extends OAuth
{
$data = json_decode($response, true);
if ($data['error_code'] != 0) {
throw new \Exception("Fetch User Info Failed:{$data['error']}");
if (isset($data['error_code']) && $data['error_code'] != 0) {
throw new \Exception("Fetch User Info Failed:{$response}");
}
$userInfo['id'] = $this->openId;

View File

@ -62,7 +62,7 @@ class WeiXin extends OAuth
$data = json_decode($response, true);
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'];
@ -75,7 +75,7 @@ class WeiXin extends OAuth
$data = json_decode($response, true);
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;