本文整理汇总了PHP中common\models\User::findIdentityByAccessToken方法的典型用法代码示例。如果您正苦于以下问题:PHP User::findIdentityByAccessToken方法的具体用法?PHP User::findIdentityByAccessToken怎么用?PHP User::findIdentityByAccessToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common\models\User
的用法示例。
在下文中一共展示了User::findIdentityByAccessToken方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
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.*',
));
*/
}
示例2: fields
/**
* @inheritdoc
*/
public function fields()
{
$fields = parent::fields();
$user = User::findIdentityByAccessToken(\Yii::$app->request->get('access-token'));
if (is_object($user) && $this->user_id == $user->user_id) {
$fields['auth'] = function () {
$user = $this->getUser();
return ['stream_userid' => $user->stream_userid, 'stream_username' => $user->stream_username, 'stream_password' => $user->stream_password];
};
} else {
$fields = [];
}
$fields['public_url'] = function () {
$name = explode("=", $this->stream_stream);
if (is_array($name) && count($name) === 3) {
$file = $name[2];
return "http://rrr.sz.xlcdn.com/?account=gtecmedia&file={$file}&type=live&service=wowza&output=player";
}
return null;
};
return $fields;
}
示例3: beforeSave
public function beforeSave($insert)
{
$user = User::findIdentityByAccessToken(Yii::$app->request->get('access-token'));
$this->review_user_id = $user->user_id;
return $this->review_rating > 0 ? true : false;
}