public function init()
{
$this->registerAssets();
parent::init();
// If API log in is allowed AND the auth-token is provided.
// todo refactor this, ATM a clug to get it working - DJE : 2015-07-23
if ($this->allowAPILogin && (Yii::$app->request->get('auth-token') != false && Yii::$app->request->get('auth-token') !== null)) {
/* Yii::$app->response->format = \yii\web\Response::FORMAT_RAW;
$headers = Yii::$app->response->headers;
$headers->add('Content-Type', 'application/json; charset=utf-8'); */
// Guest user still needs session to hide header
if (Yii::$app->request->get('auth-token') != "guest") {
$userMDL = User::findIdentityByAccessToken(Yii::$app->request->get('auth-token'));
// if the user was successfully logged in, return a message saying so
if (Yii::$app->user->login($userMDL)) {
//$returnData = ['status' => 'success' ];
} else {
//$returnData = ['status' => 'failed'];
}
//echo json_encode( $returnData );
}
Yii::$app->session->set('mobile', 'true');
Yii::$app->response->redirect(\Yii::$app->urlManager->createAbsoluteUrl('forum'));
Yii::$app->end();
}
// @depricated 2.0.0 Use the parent applications error settings
/*
\Yii::$app->setComponents(
array(
'errorHandler' => [
'errorAction' => 'site/error'
],
)
);
*/
// @todo no longer needed per Yii2
/*
// import the module-level models and components
$this->setImport(array(
$this->id.'.models.*',
$this->id.'.components.*',
));
*/
}