|
@@ -44,6 +44,12 @@ class Client extends Base
|
|
|
*/
|
|
|
private $config = null;
|
|
|
|
|
|
+ /**
|
|
|
+ * @desc refer_param
|
|
|
+ * @var array
|
|
|
+ */
|
|
|
+ private $refer_param = array();
|
|
|
+
|
|
|
public function __construct()
|
|
|
{
|
|
|
parent::__construct();
|
|
@@ -52,6 +58,7 @@ class Client extends Base
|
|
|
$this->initRequest();
|
|
|
$this->initAccount();
|
|
|
$this->initSource();
|
|
|
+ $this->initGet();
|
|
|
$this->initInvite();
|
|
|
$this->initSystem();
|
|
|
$this->initSourceType();
|
|
@@ -105,6 +112,12 @@ class Client extends Base
|
|
|
$this->session->add($this->prefix . 'oauth_source', $this->source);
|
|
|
}
|
|
|
|
|
|
+ private function initGet()
|
|
|
+ {
|
|
|
+ $this->get = (isset($this->request['get']) && $this->request['get']) ? $this->request['get'] : $this->session->get($this->prefix . 'oauth_get');
|
|
|
+ $this->session->add($this->prefix . 'oauth_get', $this->get);
|
|
|
+ }
|
|
|
+
|
|
|
private function initInvite()
|
|
|
{
|
|
|
$this->invite = (isset($this->request['invite']) && $this->request['invite']) ? $this->request['invite'] : $this->session->get($this->prefix . 'oauth_invite');
|
|
@@ -126,6 +139,27 @@ class Client extends Base
|
|
|
$this->config += Dever::config($this->config['type'])->cAll;
|
|
|
}
|
|
|
|
|
|
+ private function location($result = '')
|
|
|
+ {
|
|
|
+ if ($this->refer) {
|
|
|
+ $refer = base64_decode($this->refer);
|
|
|
+ if (!strstr($refer, 'http')) {
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+ if ($this->refer_param) {
|
|
|
+ $param = http_build_query($this->refer_param);
|
|
|
+ if (strstr($refer, '?')) {
|
|
|
+ $refer .= '&' . $param;
|
|
|
+ } else {
|
|
|
+ $refer .= '?' . $param;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Dever::location($refer);
|
|
|
+ } else {
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @desc oauth请求
|
|
|
*/
|
|
@@ -133,12 +167,7 @@ class Client extends Base
|
|
|
{
|
|
|
$info = $this->info();
|
|
|
if ($info) {
|
|
|
- if ($this->refer) {
|
|
|
- $refer = base64_decode($this->refer);
|
|
|
- Dever::location($refer);
|
|
|
- } else {
|
|
|
- return true;
|
|
|
- }
|
|
|
+ return $this->location(true);
|
|
|
}
|
|
|
$id = Dever::id();
|
|
|
$this->session->add($this->prefix . 'oauth_id', $id);
|
|
@@ -262,13 +291,7 @@ class Client extends Base
|
|
|
}
|
|
|
|
|
|
$user = $this->update($data, $id);
|
|
|
- # 跳转吧,从哪来去哪吧
|
|
|
- if ($this->refer) {
|
|
|
- $refer = base64_decode($this->refer);
|
|
|
- Dever::location($refer);
|
|
|
- } else {
|
|
|
- return $user;
|
|
|
- }
|
|
|
+ return $this->location($user);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -276,6 +299,12 @@ class Client extends Base
|
|
|
*/
|
|
|
private function update($data, $id)
|
|
|
{
|
|
|
+ if ($this->get && isset($data[$this->get])) {
|
|
|
+ $key = $this->get;
|
|
|
+ $get = $data[$key];
|
|
|
+ $this->get = array();
|
|
|
+ $this->get[$key] = $data[$key];
|
|
|
+ }
|
|
|
$this->param('user', 'access_token', $data['access_token']);
|
|
|
$this->param('user', 'openid', $data['openid']);
|
|
|
|