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 yii\filters\AccessControl;
|
||||
use yii\web\Controller;
|
||||
use yii\web\JsonResponseFormatter;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
|
||||
|
@ -216,4 +216,9 @@ class User extends ActiveRecord implements IdentityInterface
|
||||
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\classes\Debug;
|
||||
use common\models\InterviewRequest;
|
||||
use common\models\User;
|
||||
use frontend\modules\api\models\ProfileSearchForm;
|
||||
use yii\filters\auth\CompositeAuth;
|
||||
use yii\filters\auth\HttpBearerAuth;
|
||||
@ -63,7 +64,7 @@ class ProfileController extends \yii\rest\Controller
|
||||
$model->attributes = \Yii::$app->request->post();
|
||||
$model->created_at = time();
|
||||
$model->user_id = \Yii::$app->user->id;
|
||||
if ($model->save()){
|
||||
if ($model->save()) {
|
||||
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;
|
||||
|
||||
use common\behaviors\GsCors;
|
||||
use common\classes\Debug;
|
||||
use common\models\Reports;
|
||||
use frontend\modules\api\models\ReportSearchForm;
|
||||
use JsonException;
|
||||
@ -31,19 +32,19 @@ class ReportsController extends Controller
|
||||
'application/json' => Response::FORMAT_JSON,
|
||||
],
|
||||
],
|
||||
'corsFilter' => [
|
||||
'class' => GsCors::class,
|
||||
'cors' => [
|
||||
'Origin' => ['*'],
|
||||
//'Access-Control-Allow-Credentials' => true,
|
||||
'Access-Control-Allow-Headers' => [
|
||||
'Content-Type',
|
||||
'Access-Control-Allow-Headers',
|
||||
'Authorization',
|
||||
'X-Requested-With'
|
||||
],
|
||||
]
|
||||
],
|
||||
// 'corsFilter' => [
|
||||
// 'class' => GsCors::class,
|
||||
// 'cors' => [
|
||||
// 'Origin' => ['*'],
|
||||
// //'Access-Control-Allow-Credentials' => true,
|
||||
// 'Access-Control-Allow-Headers' => [
|
||||
// 'Content-Type',
|
||||
// 'Access-Control-Allow-Headers',
|
||||
// 'Authorization',
|
||||
// 'X-Requested-With'
|
||||
// ],
|
||||
// ]
|
||||
// ],
|
||||
'authenticator' => [
|
||||
'class' => CompositeAuth::class,
|
||||
'authMethods' => [
|
||||
@ -70,7 +71,7 @@ class ReportsController extends Controller
|
||||
{
|
||||
$reportsModel = new Reports();
|
||||
|
||||
$params = Yii::$app->request->get();
|
||||
$params = Yii::$app->request->post();
|
||||
$reportsModel->attributes = $params;
|
||||
|
||||
if(!$reportsModel->validate()){
|
||||
|
Loading…
Reference in New Issue
Block a user