Skip to content

Commit

Permalink
Merge pull request #2 from virbo/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
virbo authored Dec 9, 2019
2 parents 612c7a5 + eaa212a commit c0f65cb
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/Feeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ public function init()
* */
public function actFeeder($data = [])
{
Yii::$app->response->format = Response::FORMAT_JSON;

if (!is_array($data)) {
throw new BadRequestHttpException('Data must array');
}
Expand All @@ -123,10 +121,8 @@ public function actFeeder($data = [])
if ($request->data['error_code'] == 0) {
return $request->data;
} else {
if ($request->data['error_code'] === 100) {
$session = Yii::$app->session;
$session['token'] = null;
$this->getToken();
if ($request->data['error_code'] == 100) {
$this->getToken($renew = true);
} else {
throw new BadRequestHttpException('Error '.$request->data['error_code'].' - '.$request->data['error_desc']);
}
Expand All @@ -136,11 +132,11 @@ public function actFeeder($data = [])
}
}

protected function getToken()
protected function getToken($renew = false)
{
$session = Yii::$app->session;

if ($session['token'] === null) {
if ($session['token'] === null || $renew) {
$act = Json::encode([
'act' => 'GetToken',
'username' => $this->username,
Expand Down

0 comments on commit c0f65cb

Please sign in to comment.