Authored by xiaowei

PC重构 登录

... ... @@ -15,5 +15,5 @@ return array(
// 访问模式,根据自己的服务器是否支持ssl访问,若支持请选择https;若不支持请选择http
'transport' => 'http',
// 页面跳转同步通知页面路径 (需http://格式的完整路径,不允许加?id=123这类自定义参数)
'return_url' => SITE_MAIN . '/passport/login/alipaycallback',
'return_url' => SITE_MAIN . '/passport/autosign/alipaycallback',
);
... ...
<?php
defined('DOMAIN') || define('DOMAIN', $_SERVER['HTTP_HOST']);
defined('SITE_MAIN') || define('SITE_MAIN', $_SERVER['HTTP_HOST']);
return array(
'appId' => '09f4fa0661be14ec1ddeee13253a3ec4',
'appKey' => 'b4204e2055d63102',
'callback' => DOMAIN . '/passport/login/doubanback',
'appId' => '03b4e36bf13dc75a0b1eaa43d3b9560e',
'appKey' => 'f16d5913e8610672',
'callback' => SITE_MAIN . '/passport/autosign/doubanback',
'scope' => 'douban_basic_common',
);
\ No newline at end of file
... ...
... ... @@ -4,7 +4,7 @@ defined('SITE_MAIN') || define('SITE_MAIN', $_SERVER['HTTP_HOST']);
return array(
'appid' => '100229394',
'appkey' => 'c0af9c29e0900813028c2ccb42021792',
'callback' => SITE_MAIN . '/passport/login/qqcallback',
'callback' => SITE_MAIN . '/passport/autosign/qqcallback',
'scope' => 'get_user_info,add_share,upload_pic,get_idollist,get_fanslist',
'errorReport' => true,
);
\ No newline at end of file
... ...
<?php
defined('DOMAIN') || define('DOMAIN', $_SERVER['HTTP_HOST']);
defined('SITE_MAIN') || define('SITE_MAIN', $_SERVER['HTTP_HOST']);
return array(
'appId' => '783130c654c94a77ace97054ae266019',
'appKey' => '05e430de8c1e40d3a1f39ca8d3f8252c',
'callback' => DOMAIN . '/passport/login/renrenback',
'callback' => SITE_MAIN . '/passport/autosign/renrenback',
'scope' => 'publish_feed,photo_upload',
);
\ No newline at end of file
... ...
... ... @@ -4,5 +4,5 @@ defined('SITE_MAIN') || define('SITE_MAIN', $_SERVER['HTTP_HOST']);
return array(
'appId' => '3739328910',
'appKey' => '9d44cded26d048e23089e5e975c93df1',
'appCallbackUrl' => SITE_MAIN . '/passport/login/sinacallback',
'appCallbackUrl' => SITE_MAIN . '/passport/autosign/sinacallback',
);
\ No newline at end of file
... ...
<?php
use Action\AbstractAction;
use LibModels\Web\Passport\RegData;
use LibModels\Web\Passport\LoginData;
use LibModels\Web\Home\IndexData;
use Passport\PassportModel as PassportModel;
use Plugin\Helpers;
use Plugin\Images;
use Plugin\Partner\Factory;
class AutosignController extends AbstractAction
{
/**
* 支付宝登录:授权页面
*/
public function alipayAction()
{
$this->setSession('_TOKEN', '');
Factory::create('alipay')->getAuthorizeUrl();
exit();
}
/**
* QQ账号登录:授权页面
*/
public function qqAction()
{
$this->setSession('_TOKEN', '');
Factory::create('qqconnect')->getAuthorizeUrl();
exit();
}
/**
* 新浪微博账号登录:授权页面
*/
public function sinaAction()
{
$this->setSession('_TOKEN', '');
$this->go(Factory::create('sinaweibo')->getAuthorizeUrl());
}
/**
* 新浪微博账号登录:授权页面
*/
public function renrenAction()
{
$this->setSession('_TOKEN', '');
$this->go(Factory::create('renren')->getAuthorizeUrl());
}
/**
* 豆瓣账号登录:授权页面
*/
public function doubanAction()
{
$this->setSession('_TOKEN', '');
$this->go(Factory::create('douban')->getAuthorizeUrl());
}
/**
* 支付宝账号登录:回调方法
*/
public function alipaycallbackAction()
{
$realName = $this->_request->get('real_name');
$email = $this->_request->get('email');
$userId = $this->_request->get('user_id');
$result = array();
if (isset($realName, $email, $userId)) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = LoginData::signinByOpenID($realName, $userId, 'alipay', $shoppingKey);
}
//判定是否需要绑定手机号
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
$this->go(Helpers::url('/passport/bind/index', array('openId' => $userId, 'sourceType' => 'alipay', 'nickname' => $realName)));
}
$refer = $this->getCookie('refer');
if (empty($refer)) {
$refer = SITE_MAIN . '/?go=1';
}
else {
$refer = rawurldecode($refer);
}
if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid'])) {
$token = Helpers::makeToken($result['data']['uid']);
$this->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
}
else {
$this->go($refer);
}
}
/**
* QQ账号登录:回调方法
*/
public function qqcallbackAction()
{
$qqconnect = Factory::create('qqconnect');
$access = $qqconnect->getAccessToken();
/* 获取QQ腾讯用户的详细信息 */
$partnerInfo = $qqconnect->getUserInfo($access);
$result = array();
if (!empty($partnerInfo) && isset($partnerInfo['nickname'])) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['openid'], 'qq', $shoppingKey);
}
//判定是否需要绑定手机号
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
$this->go(Helpers::url('/passport/autouserinfo/userinfo', array('openId' => $access['openid'], 'sourceType' => 'qq', 'nickname' => $partnerInfo['nickname'])));
}
$refer = $this->getCookie('refer');
if (empty($refer)) {
$refer = SITE_MAIN . '/?go=1';
}
else {
$refer = rawurldecode($refer);
}
if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid'])) {
$token = Helpers::makeToken($result['data']['uid']);
$this->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
}
else {
$this->go($refer);
}
}
/**
* 新浪微博账号登录:回调方法
*/
public function sinacallbackAction()
{
$sina = Factory::create('sinaweibo');
$access = $sina->getAccessToken();
/* 获取用户的详细信息 */
$partnerInfo = $sina->getUserInfo($access);
$result = array();
if ($partnerInfo && is_array($partnerInfo)) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = LoginData::signinByOpenID($partnerInfo['screen_name'], $access['uid'], 'sina', $shoppingKey);
}
//判定是否需要绑定手机号
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
// $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['screen_name'])));
}
$refer = $this->getCookie('refer');
if (empty($refer)) {
$refer = SITE_MAIN . '/?go=1';
}
else {
$refer = rawurldecode($refer);
}
if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid'])) {
$token = Helpers::makeToken($result['data']['uid']);
$this->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
}
else {
$this->go($refer);
}
}
/**
* renren账号登录:回调方法
*/
public function renrenbackAction()
{
$renren = Factory::create('renren');
$access = $renren->getAccessToken();
/* 获取用户的详细信息 */
$partnerInfo = $renren->getUserInfo($access);
$result = array();
if ($partnerInfo && is_array($partnerInfo)) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['uid'], 'renren', $shoppingKey);
}
//判定是否需要绑定手机号
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
// $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['nick_name'])));
}
$refer = $this->getCookie('refer');
if (empty($refer)) {
$refer = SITE_MAIN . '/?go=1';
}
else {
$refer = rawurldecode($refer);
}
if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid'])) {
$token = Helpers::makeToken($result['data']['uid']);
$this->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
}
else {
$this->go($refer);
}
}
/**
* douban账号登录:回调方法
*/
public function doubanbackAction()
{
$sina = Factory::create('douban');
$access = $sina->getAccessToken();
/* 获取用户的详细信息 */
$partnerInfo = $sina->getUserInfo($access);
$result = array();
if ($partnerInfo && is_array($partnerInfo)) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['uid'], 'douban', $shoppingKey);
}
//判定是否需要绑定手机号
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
// $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['screen_name'])));
}
$refer = $this->getCookie('refer');
if (empty($refer)) {
$refer = SITE_MAIN . '/?go=1';
}
else {
$refer = rawurldecode($refer);
}
if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid'])) {
$token = Helpers::makeToken($result['data']['uid']);
$this->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
}
else {
$this->go($refer);
}
}
}
... ...
<?php
use Action\AbstractAction;
use LibModels\Web\Passport\RegData;
use LibModels\Web\Passport\LoginData;
use LibModels\Web\Home\IndexData;
use Passport\PassportModel as PassportModel;
use Plugin\Helpers;
use Plugin\Images;
use Plugin\Partner\Factory;
class AutouserinfoController extends AbstractAction
{
/**
* 第三方登录完善个人信息:
* 绑定手机号
*/
public function indexAction()
{
$this->setTitle('联合登录补全信息');
$nickname = $this->get('nickname');
$openId = $this->get('openId');
$sourceType = $this->get('sourceType');
//登录后跳转页面
$refer = $this->getCookie('refer');
if (empty($refer)) {
$refer = SITE_MAIN;
}
else {
$refer = rawurldecode($refer);
}
//获取用户
$uid = $this->getUid(true);
if (!$uid) {
$isLogin = false;
$username = '';
}
else {
$isLogin = true;
$username = $this->_uname;
}
$simpleHeader = PassportModel::getSimpleHeader($isLogin, $username);
//整合
$data = array(
'loginPage' => true,
'simpleHeader' => $simpleHeader,
'passport' => array(
'coverHref' => '',
'coverImg' => 'http://img12.static.yhbimg.com/yhb-img01/2015/12/01/07/020a0b6e7ff908d0c2bc4045b4fef42b9f.png?imageView/2/w/252/h/190',
),
);
$this->_view->display('index', $data);
}
/**
* 完善信息页面
*/
public function userInfoAction()
{
//获取用户
$uid = $this->getUid(true);
$nickname = $this->get('nickname');
$openId = $this->get('openId');
$sourceType = $this->get('sourceType');
if (!$uid) {
$isLogin = false;
$username = '';
}
else {
$isLogin = true;
$username = $this->_uname;
}
$simpleHeader = PassportModel::getSimpleHeader($isLogin, $username);
//整合
$data = array(
'simpleHeader' => $simpleHeader,
'passport' => array(
'coverHref' => '',
'coverImg' => 'http://img12.static.yhbimg.com/yhb-img01/2015/12/01/07/020a0b6e7ff908d0c2bc4045b4fef42b9f.png?imageView/2/w/252/h/190',
'goShoppingUrl' => SITE_MAIN,
'completeInfoUrl' => Helpers::url('/passport/autouserinfo/index', array('openId' => $openId, 'sourceType' => $sourceType, 'nickname' => $nickname)),
),
);
$this->_view->display('userinfo', $data);
}
/*
* 发送绑定验证吗
*/
/*
* 验证图形验证码
*/
/*
* 验证短信验证码
*/
/*
* 绑定手机号
*/
}
... ...
... ... @@ -26,7 +26,7 @@ class LoginController extends AbstractAction
$this->setCookie('_TOKEN', '');
//登录后跳转页面
$refer = $this->get('refer');
$refer = empty($_SERVER["HTTP_REFERER"])?'':$_SERVER["HTTP_REFERER"];
if (!empty($refer)) {
$this->setCookie('refer', $refer);
}
... ... @@ -55,17 +55,17 @@ class LoginController extends AbstractAction
'simpleHeader' => $simpleHeader,
'passport' => array(
'coverHref' => $coverHref,
'coverImg' => $coverImg,
'coverImg' => !empty($coverImg)?$coverImg:'http://img12.static.yhbimg.com/yhb-img01/2015/12/01/07/020a0b6e7ff908d0c2bc4045b4fef42b9f.png?imageView/2/w/252/h/190',
'countryCode' => '+86',
'countryName' => '中国',
'countryList' => RegData::getAreasData(),
'forgetPwd' => Helpers::url('/passport/back/index'),
'fastReg' => Helpers::url('/reg.html'),
'qqLogin' => Helpers::url('/passport/login/qq'),
'weiboLogin' => Helpers::url('/passport/login/sina'),
'alipayLogin' => Helpers::url('/passport/login/alipay'),
'doubanLogin' => Helpers::url('/passport/login/douban'),
'renrenLogin' => Helpers::url('/passport/login/renren'),
'qqLogin' => Helpers::url('/passport/autosign/qq'),
'weiboLogin' => Helpers::url('/passport/autosign/sina'),
'alipayLogin' => Helpers::url('/passport/autosign/alipay'),
'doubanLogin' => Helpers::url('/passport/autosign/douban'),
'renrenLogin' => Helpers::url('/passport/autosign/renren'),
),
);
... ... @@ -160,262 +160,4 @@ class LoginController extends AbstractAction
$this->go($refer);
}
//第三方登录
/**
* 支付宝登录:授权页面
*/
public function alipayAction()
{
$this->setSession('_TOKEN', '');
Factory::create('alipay')->getAuthorizeUrl();
exit();
}
/**
* QQ账号登录:授权页面
*/
public function qqAction()
{
$this->setSession('_TOKEN', '');
Factory::create('qqconnect')->getAuthorizeUrl();
exit();
}
/**
* 新浪微博账号登录:授权页面
*/
public function sinaAction()
{
$this->setSession('_TOKEN', '');
$this->go(Factory::create('sinaweibo')->getAuthorizeUrl());
}
/**
* 新浪微博账号登录:授权页面
*/
public function renrenAction()
{
$this->setSession('_TOKEN', '');
$this->go(Factory::create('renren')->getAuthorizeUrl());
}
/**
* 豆瓣账号登录:授权页面
*/
public function doubanAction()
{
$this->setSession('_TOKEN', '');
$this->go(Factory::create('douban')->getAuthorizeUrl());
}
/**
* 支付宝账号登录:回调方法
*/
public function alipaycallbackAction()
{
$realName = $this->_request->get('real_name');
$email = $this->_request->get('email');
$userId = $this->_request->get('user_id');
$result = array();
if (isset($realName, $email, $userId)) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = LoginData::signinByOpenID($realName, $userId, 'alipay', $shoppingKey);
}
//判定是否需要绑定手机号
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
$this->go(Helpers::url('/passport/bind/index', array('openId' => $userId, 'sourceType' => 'alipay', 'nickname' => $realName)));
}
$refer = $this->getCookie('refer');
if (empty($refer)) {
$refer = SITE_MAIN . '/?go=1';
}
else {
$refer = rawurldecode($refer);
}
if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid'])) {
$token = Helpers::makeToken($result['data']['uid']);
$this->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
}
else {
$this->go($refer);
}
}
/**
* QQ账号登录:回调方法
*/
public function qqcallbackAction()
{
$qqconnect = Factory::create('qqconnect');
$access = $qqconnect->getAccessToken();
/* 获取QQ腾讯用户的详细信息 */
$partnerInfo = $qqconnect->getUserInfo($access);
$result = array();
if (!empty($partnerInfo) && isset($partnerInfo['nickname'])) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['openid'], 'qq', $shoppingKey);
}
//判定是否需要绑定手机号
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
// $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['openid'], 'sourceType' => 'qq', 'nickname' => $partnerInfo['nickname'])));
}
$refer = $this->getCookie('refer');
if (empty($refer)) {
$refer = SITE_MAIN . '/?go=1';
}
else {
$refer = rawurldecode($refer);
}
if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid'])) {
$token = Helpers::makeToken($result['data']['uid']);
$this->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
}
else {
$this->go($refer);
}
}
/**
* 新浪微博账号登录:回调方法
*/
public function sinacallbackAction()
{
$sina = Factory::create('sinaweibo');
$access = $sina->getAccessToken();
/* 获取用户的详细信息 */
$partnerInfo = $sina->getUserInfo($access);
$result = array();
if ($partnerInfo && is_array($partnerInfo)) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = LoginData::signinByOpenID($partnerInfo['screen_name'], $access['uid'], 'sina', $shoppingKey);
}
//判定是否需要绑定手机号
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
// $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['screen_name'])));
}
$refer = $this->getCookie('refer');
if (empty($refer)) {
$refer = SITE_MAIN . '/?go=1';
}
else {
$refer = rawurldecode($refer);
}
if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid'])) {
$token = Helpers::makeToken($result['data']['uid']);
$this->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
}
else {
$this->go($refer);
}
}
/**
* renren账号登录:回调方法
*/
public function renrenbackAction()
{
$renren = Factory::create('renren');
$access = $renren->getAccessToken();
/* 获取用户的详细信息 */
$partnerInfo = $renren->getUserInfo($access);
$result = array();
if ($partnerInfo && is_array($partnerInfo)) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['uid'], 'renren', $shoppingKey);
}
//判定是否需要绑定手机号
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
// $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['nick_name'])));
}
$refer = $this->getCookie('refer');
if (empty($refer)) {
$refer = SITE_MAIN . '/?go=1';
}
else {
$refer = rawurldecode($refer);
}
if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid'])) {
$token = Helpers::makeToken($result['data']['uid']);
$this->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
}
else {
$this->go($refer);
}
}
/**
* douban账号登录:回调方法
*/
public function doubanbackAction()
{
$sina = Factory::create('douban');
$access = $sina->getAccessToken();
/* 获取用户的详细信息 */
$partnerInfo = $sina->getUserInfo($access);
$result = array();
if ($partnerInfo && is_array($partnerInfo)) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['uid'], 'douban', $shoppingKey);
}
//判定是否需要绑定手机号
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
// $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['screen_name'])));
}
$refer = $this->getCookie('refer');
if (empty($refer)) {
$refer = SITE_MAIN . '/?go=1';
}
else {
$refer = rawurldecode($refer);
}
if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid'])) {
$token = Helpers::makeToken($result['data']['uid']);
$this->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
}
else {
$this->go($refer);
}
}
}
... ...