mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-25 12:09:09 +08:00
* Merge branch 'master' of gitee.com:koogua/course-tencent-cloud into develop * Merge branch 'demo' of gitee.com:koogua/course-tencent-cloud into develop * Merge remote-tracking branch 'github/develop' into develop * Merge branch 'develop' of https://gitee.com/koogua/course-tencent-clou… * 更改QQ登录获取ACCESS_TOKEN的请求方式 * Merge branch 'master' into develop * Merge branch 'master' of gitee.com:koogua/course-tencent-cloud into develop * !44 v1.2.1阶段性合并 * 优化开发登录逻辑 * v1.2.1阶段性合并 (#13) * !43 v1.2.0阶段性合并 * Merge branches 'develop' and 'master' of https://gitee.com/koogua/cour… * 优化开发登录,计划任务执行路径,周期 * !41 修复课程分类未过滤2 * !39 修复课程分类未过滤 * Merge branch 'master' of https://gitee.com/koogua/course-tencent-cloud into demo * Merge branch 'master' of https://gitee.com/koogua/course-tencent-cloud… * Merge branch 'develop' of https://gitee.com/koogua/course-tencent-clou… * 优化第三方登录,修复注册密码加密问题 * !33 开放登录阶段性合并 * Merge branch 'xiaochong0302/I280IZ' of https://gitee.com/koogua/course… * Merge remote-tracking branch 'gitee/xiaochong0302/I280IZ' into xiaocho… * 初步完成开放登录,待线上测试7 * !31 开放登录线上测试6 * Merge branch 'demo' of gitee.com:koogua/course-tencent-cloud into xiao… * 初步完成开放登录,待线上测试6 * !30 开放登录线上测试5 * !29 开放登录线上测试5 * 初步完成开放登录,待线上测试5 * !28 开放登录线上测试4 * 初步完成开放登录,待线上测试4 * !27 开放登录线上测试3 * 初步完成开放登录,待线上测试3 * !26 开放登录线上测试2 * 初步完成开放登录,待线上测试2 * !25 开放登录线上测试 * 初步完成开放登录,待线上测试 * !24 修复添加课时后进入编辑页面500错误 * !22 验证更新h5支付 * 更新H5支付方式 * Merge remote-tracking branch 'remotes/gitee/develop' into demo * 更新H5支付方式 * !20 验证更新h5支付 * 更新H5支付方式 * v1.2.0阶段性合并 (#11) * Merge remote-tracking branch 'remotes/gitee/master' into develop * Merge pull request #10 from xiaochong0302/develop * Merge branch 'develop' of https://gitee.com/koogua/course-tencent-clou… * 增加微信H5支付需要的Referer头信息 * Merge pull request #8 from xiaochong0302/develop * !16 v1.2.0阶段性合并 * 删除调试断点代码 * 删除重复的signature方法 * Merge branch 'develop' of https://gitee.com/koogua/course-tencent-clou… * demo后台增加统计 * Merge pull request #5 from xiaochong0302/develop * Merge pull request #3 from xiaochong0302/develop * !5 更新版本号1.1.0 * !4 v1.1.0版本develop->demo * Merge branch 'develop' into demo * 1.增加changelog.md * Merge branch 'develop' into demo * Merge branch 'develop' into demo * Merge branch 'develop' into demo * !1 精简优化代码 * Merge branch 'develop' into demo * 合并修改
141 lines
3.5 KiB
PHP
141 lines
3.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Home\Controllers;
|
|
|
|
use App\Http\Home\Services\Connect as ConnectService;
|
|
use App\Models\Connect as ConnectModel;
|
|
|
|
/**
|
|
* @RoutePrefix("/oauth")
|
|
*/
|
|
class ConnectController extends Controller
|
|
{
|
|
|
|
/**
|
|
* @Get("/qq", name="home.oauth.qq")
|
|
*/
|
|
public function qqAction()
|
|
{
|
|
$service = new ConnectService();
|
|
|
|
$url = $service->getAuthorizeUrl(ConnectModel::PROVIDER_QQ);
|
|
|
|
return $this->response->redirect($url, true);
|
|
}
|
|
|
|
/**
|
|
* @Get("/weixin", name="home.oauth.weixin")
|
|
*/
|
|
public function weixinAction()
|
|
{
|
|
$service = new ConnectService();
|
|
|
|
$url = $service->getAuthorizeUrl(ConnectModel::PROVIDER_WEIXIN);
|
|
|
|
return $this->response->redirect($url, true);
|
|
}
|
|
|
|
/**
|
|
* @Get("/weibo", name="home.oauth.weibo")
|
|
*/
|
|
public function weiboAction()
|
|
{
|
|
$service = new ConnectService();
|
|
|
|
$url = $service->getAuthorizeUrl(ConnectModel::PROVIDER_WEIBO);
|
|
|
|
return $this->response->redirect($url, true);
|
|
}
|
|
|
|
/**
|
|
* @Get("/qq/callback", name="home.oauth.qq_callback")
|
|
*/
|
|
public function qqCallbackAction()
|
|
{
|
|
$this->handleCallback(ConnectModel::PROVIDER_QQ);
|
|
}
|
|
|
|
/**
|
|
* @Get("/weixin/callback", name="home.oauth.weixin_callback")
|
|
*/
|
|
public function weixinCallbackAction()
|
|
{
|
|
$this->handleCallback(ConnectModel::PROVIDER_WEIXIN);
|
|
}
|
|
|
|
/**
|
|
* @Get("/weibo/callback", name="home.oauth.weibo_callback")
|
|
*/
|
|
public function weiboCallbackAction()
|
|
{
|
|
$this->handleCallback(ConnectModel::PROVIDER_WEIBO);
|
|
}
|
|
|
|
/**
|
|
* @Get("/weibo/refuse", name="home.oauth.weibo_refuse")
|
|
*/
|
|
public function weiboRefuseAction()
|
|
{
|
|
return $this->response->redirect(['for' => 'home.account.login']);
|
|
}
|
|
|
|
/**
|
|
* @Post("/bind/login", name="home.oauth.bind_login")
|
|
*/
|
|
public function bindLoginAction()
|
|
{
|
|
$service = new ConnectService();
|
|
|
|
$service->bindLogin();
|
|
|
|
$location = $this->url->get(['for' => 'home.uc.account']);
|
|
|
|
return $this->jsonSuccess(['location' => $location]);
|
|
}
|
|
|
|
/**
|
|
* @Post("/bind/register", name="home.oauth.bind_register")
|
|
*/
|
|
public function bindRegisterAction()
|
|
{
|
|
$service = new ConnectService();
|
|
|
|
$service->bindRegister();
|
|
|
|
$location = $this->url->get(['for' => 'home.uc.account']);
|
|
|
|
return $this->jsonSuccess(['location' => $location]);
|
|
}
|
|
|
|
protected function handleCallback($provider)
|
|
{
|
|
$code = $this->request->getQuery('code');
|
|
$state = $this->request->getQuery('state');
|
|
|
|
$service = new ConnectService();
|
|
|
|
$openUser = $service->getOpenUserInfo($code, $state, $provider);
|
|
$connect = $service->getConnectRelation($openUser['id'], $openUser['provider']);
|
|
|
|
if ($this->authUser->id > 0) {
|
|
if ($openUser) {
|
|
$service->bindUser($openUser);
|
|
return $this->response->redirect(['for' => 'home.uc.account']);
|
|
}
|
|
} else {
|
|
if ($connect && $connect->deleted == 0) {
|
|
$service->authLogin($connect);
|
|
return $this->response->redirect(['for' => 'home.index']);
|
|
}
|
|
}
|
|
|
|
$captcha = $service->getSettings('captcha');
|
|
|
|
$this->view->pick('connect/bind');
|
|
$this->view->setVar('captcha', $captcha);
|
|
$this->view->setVar('provider', $provider);
|
|
$this->view->setVar('open_user', $openUser);
|
|
}
|
|
|
|
}
|