用这个 function 替换 app/account/openid.php 里面那个函数,建议通过审核之后改回来
https://gist.github.com/explon/7426697
<?php
public function qq_login_callback_action()
{
if (! $_GET['code'])
{
H::redirect_msg(AWS_APP::lang()->_t('与 QQ 通信出错, 请重新登录'), "/account/login/");
}
if (! AWS_APP::session()->QQConnect['access_token'])
{
if (! $this->model('openid_qq')->request_access_token(get_js_url('/account/openid/qq_login_callback/')))
{
H::redirect_msg(AWS_APP::lang()->_t('与 QQ 通信出错, 请重新登录'), "/account/login/");
}
}
if (! AWS_APP::session()->QQConnect['access_token'] OR ! $uinfo = $this->model('openid_qq')->request_user_info())
{
H::redirect_msg(AWS_APP::lang()->_t('与 QQ 通信出错, 请重新登录'), "/account/login/");
}
if ($qq_user = $this->model('openid_qq')->get_user_info_by_open_id(load_class('Services_Tencent_QQConnect_V2')->get_openid()))
{
$user_info = $this->model('account')->get_user_info_by_uid($qq_user['uid']);
HTTP::set_cookie('_user_login', get_login_cookie_hash($user_info['user_name'], $user_info['password'], $user_info['salt'], $user_info['uid'], false));
$this->model('openid_qq')->update_token($qq_user['name'], AWS_APP::session()->QQConnect['access_token']);
if (get_setting('ucenter_enabled') == 'Y')
{
HTTP::redirect('/account/sync_login/');
}
else
{
HTTP::redirect('/');
}
}
else
{
// Modify by anwsion
//H::redirect_msg(AWS_APP::lang()->_t('该 QQ 号未与本站账户绑定'), get_setting('base_url'));
if (get_setting('invite_reg_only') == 'Y')
{
H::redirect_msg(AWS_APP::lang()->_t('本站只能通过邀请注册'));
}
if (! AWS_APP::session()->QQConnect['access_token'] OR ! $uinfo = $this->model('openid_qq')->request_user_info())
{
H::redirect_msg(AWS_APP::lang()->_t('与 QQ 通信出错, 请重新登录'), '/account/login/');
}
else
{
$qq_login_user_name = $uinfo['nickname'] . '_' . rand(100000000, 999999999);
if (get_setting('ucenter_enabled') == 'Y')
{
$result = $this->model('ucenter')->register($qq_login_user_name, rand(111111111, 999999999), 'qq_login' . rand(100000000, 999999999) . '@qq.com', true);
if (is_array($result))
{
$uid = $result['user_info']['uid'];
}
else
{
H::redirect_msg($result);
}
}
else
{
$uid = $this->model('account')->user_register($qq_login_user_name, rand(111111111, 999999999), 'qq_login' . rand(100000000, 999999999) . '@qq.com', true);
}
$user_info = $this->model('account')->get_user_info_by_uid($uid);
HTTP::set_cookie('_user_login', get_login_cookie_hash($user_info['user_name'], $user_info['password'], $user_info['salt'], $user_info['uid'], false));
$this->model('openid_qq')->bind_account($uinfo, get_js_url('/'), $uid);
}
}
}