Hello @samdark,
Please below is my class with my behaviors method and some additional code included:
class AuthenticationController extends ActiveController
{
private $request;
/**
* It is important verb is used to control HTTP request type to accept.
* {@inheritdoc}
* @return array
*/
public function behaviors()
{
return [
'corsFilter' => [
'class' => \yii\filters\Cors::className(),
'cors' => [
// restrict access to
//'Origin' => ['http://localhost', 'http://www.myserver.com'],
'Origin' => ['http://localhost','*'],
'Access-Control-Request-Method' => ['POST', 'PUT', 'GET'],
// Allow only POST and PUT methods
'Access-Control-Request-Headers' => ['X-Wsse'],
// Allow only headers 'X-Wsse'
'Access-Control-Allow-Credentials' => true,
// Allow OPTIONS caching
'Access-Control-Max-Age' => 3600,
// Allow the X-Pagination-Current-Page header to be exposed to the browser.
'Access-Control-Expose-Headers' => ['X-Pagination-Current-Page'],
],
],
'verbs' => [
'class' => \yii\filters\VerbFilter::className(),
'actions' => [
'login' => ['post'],
'logout' => ['post'],
'signup' => ['post'],
'forgot-password' => ['post'],
'recover-password' => ['post'],
],
],
'authenticator' => [
'class' => HttpBearerAuth::className(),
'only' => ['logout'],
],
];
}
public function beforeAction($action)
{
$this->request = \yii::$app->request->post();
return parent::beforeAction($action);
}
/**
* {@inheritdoc}
*/
public function actions()
{
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
'captcha' => [
'class' => 'yii\captcha\CaptchaAction',
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
],
];
}