作者 王晓刚
1 个管道 的构建 通过 耗费 2 秒

调试授权登录

... ... @@ -66,8 +66,9 @@ class WechatBase extends Controller
/**
* 检查微信用户登录
* @param null $target_url
*/
public function checkWeChatUserLogin()
public function checkWeChatUserLogin($target_url = null)
{
$userId = get_current_user_id();
if (empty($userId)) {
... ... @@ -80,7 +81,9 @@ class WechatBase extends Controller
],
];
$app = new Application($config);
$target_url='http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if(empty($target_url)){
$target_url='http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
}
session('target_url',$target_url);
$app->oauth->redirect()->send();
}
... ...
... ... @@ -23,12 +23,8 @@ class Goods extends WechatBase
//判断是否授权
$user_id = get_current_user_id();
if(empty($user_id)){
dump(url('','',false,true));
echo $this->request->controller();
echo $this->request->module();
echo $this->request->action();
exit();
$this->redirect('user/authorization_view');
$target_url = UrlEncode(url('','',false,true));
$this->redirect('user/authorization_view',array('target_url'=>$target_url));
}
$this->user_id = $user_id;
}
... ...
... ... @@ -153,7 +153,13 @@ class User extends WechatBase
* 授权
*/
public function authorization(){
$this->checkWeChatUserLogin();
$target_url = $this->request->param('target_url');
if(empty($target_url)){
$target_url = url('home/index/index','',false,true);
}else{
$target_url = UrlDecode($target_url);
}
$this->checkWeChatUserLogin($target_url);
}
/**
... ...
... ... @@ -65,7 +65,7 @@
</body>
<script>
function login(){
window.location.href="{:url('home/user/authorization')}";
window.location.href="{:url('home/user/authorization',array('target_url'=>$target_url))}";
}
</script>
</html>
\ No newline at end of file
... ...