add qrcode lib

This commit is contained in:
2022-02-06 00:04:34 +01:00
parent 9856411844
commit 525a829da3
6 changed files with 433 additions and 194 deletions

View File

@@ -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 [];
// }
}