bug fixing
This commit is contained in:
parent
6cd7af5fd0
commit
2b1c3319f4
@ -3,7 +3,6 @@
|
|||||||
namespace customerapi\controllers;
|
namespace customerapi\controllers;
|
||||||
|
|
||||||
|
|
||||||
use common\helpers\CorsCustom;
|
|
||||||
use common\models\Customer;
|
use common\models\Customer;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Lcobucci\JWT\Token;
|
use Lcobucci\JWT\Token;
|
||||||
@ -19,13 +18,20 @@ class RestController extends Controller
|
|||||||
public function behaviors()
|
public function behaviors()
|
||||||
{
|
{
|
||||||
$behaviors = parent::behaviors();
|
$behaviors = parent::behaviors();
|
||||||
|
|
||||||
$behaviors['authenticator'] = [
|
$behaviors['authenticator'] = [
|
||||||
'class' => JwtHttpBearerAuth::class,
|
'class' => JwtHttpBearerAuth::class,
|
||||||
'auth' => [$this, 'auth'],
|
'auth' => [$this, 'auth'],
|
||||||
'optional' => $this->getOptionalActions(),
|
'optional' => $this->getOptionalActions(),
|
||||||
];
|
];
|
||||||
|
$behaviors['corsFilter'] = [
|
||||||
|
'class' => Cors::class,
|
||||||
|
'cors' => [
|
||||||
|
// restrict access to
|
||||||
|
'Origin' => ['https://botondfitness.hu'],
|
||||||
|
// Allow credentials (cookies, authorization headers, etc.) to be exposed to the browser
|
||||||
|
'Access-Control-Allow-Credentials' => true,
|
||||||
|
]
|
||||||
|
];
|
||||||
return $behaviors;
|
return $behaviors;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +50,7 @@ class RestController extends Controller
|
|||||||
$customer = Customer::findOne(['id_customer' => $uid]);
|
$customer = Customer::findOne(['id_customer' => $uid]);
|
||||||
if (isset($customer)) {
|
if (isset($customer)) {
|
||||||
\Yii::$app->user->setIdentity($customer);
|
\Yii::$app->user->setIdentity($customer);
|
||||||
return $customer;
|
return $customer;
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Yii::error('Failed to load customer: ' . $e->getMessage());
|
Yii::error('Failed to load customer: ' . $e->getMessage());
|
||||||
@ -62,3 +68,4 @@ class RestController extends Controller
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user