some fix
This commit is contained in:
parent
c8540c41b3
commit
dd11a9a88c
@ -9,6 +9,7 @@ use common\models\Reports;
|
|||||||
use backend\modules\reports\models\ReportsSearch;
|
use backend\modules\reports\models\ReportsSearch;
|
||||||
use yii\filters\AccessControl;
|
use yii\filters\AccessControl;
|
||||||
use yii\web\Controller;
|
use yii\web\Controller;
|
||||||
|
use yii\web\JsonResponseFormatter;
|
||||||
use yii\web\NotFoundHttpException;
|
use yii\web\NotFoundHttpException;
|
||||||
use yii\filters\VerbFilter;
|
use yii\filters\VerbFilter;
|
||||||
|
|
||||||
|
@ -216,4 +216,9 @@ class User extends ActiveRecord implements IdentityInterface
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getUserCard()
|
||||||
|
{
|
||||||
|
return $this->hasOne(UserCard::class, ['id_user' => 'id']);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ namespace frontend\modules\api\controllers;
|
|||||||
use common\behaviors\GsCors;
|
use common\behaviors\GsCors;
|
||||||
use common\classes\Debug;
|
use common\classes\Debug;
|
||||||
use common\models\InterviewRequest;
|
use common\models\InterviewRequest;
|
||||||
|
use common\models\User;
|
||||||
use frontend\modules\api\models\ProfileSearchForm;
|
use frontend\modules\api\models\ProfileSearchForm;
|
||||||
use yii\filters\auth\CompositeAuth;
|
use yii\filters\auth\CompositeAuth;
|
||||||
use yii\filters\auth\HttpBearerAuth;
|
use yii\filters\auth\HttpBearerAuth;
|
||||||
@ -63,7 +64,7 @@ class ProfileController extends \yii\rest\Controller
|
|||||||
$model->attributes = \Yii::$app->request->post();
|
$model->attributes = \Yii::$app->request->post();
|
||||||
$model->created_at = time();
|
$model->created_at = time();
|
||||||
$model->user_id = \Yii::$app->user->id;
|
$model->user_id = \Yii::$app->user->id;
|
||||||
if ($model->save()){
|
if ($model->save()) {
|
||||||
return ['status' => 'success'];
|
return ['status' => 'success'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,4 +73,14 @@ class ProfileController extends \yii\rest\Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function actionMe()
|
||||||
|
{
|
||||||
|
if(isset(\Yii::$app->user->id)){
|
||||||
|
$user = User::find()->with('userCard')->where(['id' => \Yii::$app->user->id])->one();
|
||||||
|
}
|
||||||
|
|
||||||
|
\Yii::$app->response->statusCode = 401;
|
||||||
|
return ['status' => 'error', 'errors' => 'No authorized'];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace frontend\modules\api\controllers;
|
namespace frontend\modules\api\controllers;
|
||||||
|
|
||||||
use common\behaviors\GsCors;
|
use common\behaviors\GsCors;
|
||||||
|
use common\classes\Debug;
|
||||||
use common\models\Reports;
|
use common\models\Reports;
|
||||||
use frontend\modules\api\models\ReportSearchForm;
|
use frontend\modules\api\models\ReportSearchForm;
|
||||||
use JsonException;
|
use JsonException;
|
||||||
@ -31,19 +32,19 @@ class ReportsController extends Controller
|
|||||||
'application/json' => Response::FORMAT_JSON,
|
'application/json' => Response::FORMAT_JSON,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'corsFilter' => [
|
// 'corsFilter' => [
|
||||||
'class' => GsCors::class,
|
// 'class' => GsCors::class,
|
||||||
'cors' => [
|
// 'cors' => [
|
||||||
'Origin' => ['*'],
|
// 'Origin' => ['*'],
|
||||||
//'Access-Control-Allow-Credentials' => true,
|
// //'Access-Control-Allow-Credentials' => true,
|
||||||
'Access-Control-Allow-Headers' => [
|
// 'Access-Control-Allow-Headers' => [
|
||||||
'Content-Type',
|
// 'Content-Type',
|
||||||
'Access-Control-Allow-Headers',
|
// 'Access-Control-Allow-Headers',
|
||||||
'Authorization',
|
// 'Authorization',
|
||||||
'X-Requested-With'
|
// 'X-Requested-With'
|
||||||
],
|
// ],
|
||||||
]
|
// ]
|
||||||
],
|
// ],
|
||||||
'authenticator' => [
|
'authenticator' => [
|
||||||
'class' => CompositeAuth::class,
|
'class' => CompositeAuth::class,
|
||||||
'authMethods' => [
|
'authMethods' => [
|
||||||
@ -70,7 +71,7 @@ class ReportsController extends Controller
|
|||||||
{
|
{
|
||||||
$reportsModel = new Reports();
|
$reportsModel = new Reports();
|
||||||
|
|
||||||
$params = Yii::$app->request->get();
|
$params = Yii::$app->request->post();
|
||||||
$reportsModel->attributes = $params;
|
$reportsModel->attributes = $params;
|
||||||
|
|
||||||
if(!$reportsModel->validate()){
|
if(!$reportsModel->validate()){
|
||||||
|
Loading…
Reference in New Issue
Block a user