bug fixing
This commit is contained in:
parent
6cd7af5fd0
commit
2b1c3319f4
@ -3,7 +3,6 @@
|
||||
namespace customerapi\controllers;
|
||||
|
||||
|
||||
use common\helpers\CorsCustom;
|
||||
use common\models\Customer;
|
||||
use Exception;
|
||||
use Lcobucci\JWT\Token;
|
||||
@ -19,13 +18,20 @@ class RestController extends Controller
|
||||
public function behaviors()
|
||||
{
|
||||
$behaviors = parent::behaviors();
|
||||
|
||||
$behaviors['authenticator'] = [
|
||||
'class' => JwtHttpBearerAuth::class,
|
||||
'auth' => [$this, 'auth'],
|
||||
'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;
|
||||
}
|
||||
|
||||
@ -44,7 +50,7 @@ class RestController extends Controller
|
||||
$customer = Customer::findOne(['id_customer' => $uid]);
|
||||
if (isset($customer)) {
|
||||
\Yii::$app->user->setIdentity($customer);
|
||||
return $customer;
|
||||
return $customer;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
Yii::error('Failed to load customer: ' . $e->getMessage());
|
||||
@ -62,3 +68,4 @@ class RestController extends Controller
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user