Your IP : 216.73.216.79


Current Path : /var/www/html/swcorpdataraya/frontend/controllers/
Upload File :
Current File : /var/www/html/swcorpdataraya/frontend/controllers/AiDynawebController.php

<?php

namespace frontend\controllers;

use Yii;
use yii\web\Controller;
use yii\filters\VerbFilter;
use backend\modules\aidynaweb\components\DynawebApi;

/**
 * FileQnaController implements the CRUD actions for FileQna model.
 */
class AiDynawebController extends Controller
{

    /**
     * @inheritdoc
     */
    public function beforeAction($action)
    {            
        // // if ($action->id == 'my-method') {
        //     $this->enableCsrfValidation = false;
        // // }

        return parent::beforeAction($action);
    }

    /**
     * {@inheritdoc}
     */
    public function behaviors()
    {
        return [
            'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    'delete' => ['POST'],
                    'get-bearer' => ['POST']
                ],
            ],
        ];
    }

    /**
     * Lists all FileQna models.
     * @return mixed
     */
    public function actionIndex(){

    }

    /**
     * Lists all FileQna models.
     * @return mixed
     */
    public function actionGetBearer()
    {   
        try {
            if($post = Yii::$app->request->post()) {

                $this->asJson([
                    'success' => true,
                    'token' => DynawebApi::getToken($post['payload'], $post['nonce']),
                    'payload' => $post['payload'] . $post['nonce']
                ]
                );
            }
        } catch (\Throwable $t) {
            return $this->asJson(['success' => false, 'message' => $t->getMessage()]);
        }
    }
}