add qrcode lib
This commit is contained in:
@@ -17,11 +17,11 @@ class RestController extends Controller
|
||||
public function behaviors()
|
||||
{
|
||||
$behaviors = parent::behaviors();
|
||||
$behaviors['authenticator'] = [
|
||||
'class' => JwtHttpBearerAuth::class,
|
||||
'auth' => [$this, 'auth'],
|
||||
'optional' => $this->getOptionalActions(),
|
||||
];
|
||||
// $behaviors['authenticator'] = [
|
||||
// 'class' => JwtHttpBearerAuth::class,
|
||||
// 'auth' => [$this, 'auth'],
|
||||
// 'optional' => $this->getOptionalActions(),
|
||||
// ];
|
||||
return $behaviors;
|
||||
}
|
||||
|
||||
@@ -30,31 +30,31 @@ class RestController extends Controller
|
||||
* @param Token $token
|
||||
* @return Customer|null
|
||||
*/
|
||||
public function auth($token)
|
||||
{
|
||||
if ( !isset($token ) ) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
$uid = (string) $token->getClaim('uid');
|
||||
$customer = Customer::findOne(['id_customer' => $uid]);
|
||||
if (isset($customer)) {
|
||||
\Yii::$app->user->setIdentity($customer);
|
||||
return $customer;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
Yii::error('Failed to load customer: ' . $e->getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AuthMethod::$optional
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptionalActions(){
|
||||
return [];
|
||||
}
|
||||
// public function auth($token)
|
||||
// {
|
||||
// if ( !isset($token ) ) {
|
||||
// return null;
|
||||
// }
|
||||
// try {
|
||||
// $uid = (string) $token->getClaim('uid');
|
||||
// $customer = Customer::findOne(['id_customer' => $uid]);
|
||||
// if (isset($customer)) {
|
||||
// \Yii::$app->user->setIdentity($customer);
|
||||
// return $customer;
|
||||
// }
|
||||
// } catch (Exception $e) {
|
||||
// Yii::error('Failed to load customer: ' . $e->getMessage());
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @see AuthMethod::$optional
|
||||
// * @return array
|
||||
// */
|
||||
// protected function getOptionalActions(){
|
||||
// return [];
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user