bug fixing

This commit is contained in:
Roland Schneider 2021-09-28 20:53:50 +02:00
parent e6f8660d78
commit 6cd7af5fd0
2 changed files with 3 additions and 29 deletions

View File

@ -18,23 +18,12 @@ use yii\web\UnauthorizedHttpException;
/** @noinspection PhpUnused */
class LoginController extends Controller
class LoginController extends RestController
{
public function behaviors()
protected function getOptionalActions()
{
$behaviors = parent::behaviors();
$behaviors['corsFilter'] = [
'class' => CorsCustom::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 ['login'];
}
/**

View File

@ -20,26 +20,11 @@ class RestController extends Controller
{
$behaviors = parent::behaviors();
$auth = $behaviors['authenticator'];
unset($behaviors['authenticator']);
$behaviors['corsFilter'] = [
'class' => Cors::class,
'cors' => [
'Origin' => ['https://botondfitness.hu'],
'Access-Control-Request-Method' => ['POST', 'GET', 'OPTIONS'],
'Access-Control-Allow-Headers' => ['*'],
'Access-Control-Expose-Headers' => ['*']
],
];
$behaviors['authenticator'] = $auth;
$behaviors['authenticator'] = [
'class' => JwtHttpBearerAuth::class,
'auth' => [$this, 'auth'],
'optional' => $this->getOptionalActions(),
];
$behaviors['authenticator']['except'] = ['options'];
return $behaviors;
}