MainController.php 825 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace mobile\controllers;
  3. use biz\user\services\UserService;
  4. use common\components\jwt;
  5. use common\components\token;
  6. use Yii;
  7. use yii\db\Exception;
  8. use yii\web\Controller;
  9. class MainController extends PublicController
  10. {
  11. public $enableCsrfValidation = false;
  12. public function actionIndex()
  13. {
  14. $host = Yii::$app->request->getHostInfo();
  15. $fullUrl = Yii::$app->request->url;
  16. $token = '';
  17. if(strpos($fullUrl, 'token')){
  18. $parse = parse_url($fullUrl);
  19. if (isset($parse['query'])) {
  20. parse_str($parse['query'], $queryArray);
  21. if (isset($queryArray['token']) && !empty($queryArray['token'])) {
  22. $token = $queryArray['token'];
  23. }
  24. }
  25. }
  26. return $this->renderPartial('index', ['host' => $host, 'token' => $token]);
  27. }
  28. public function actionJwt()
  29. {
  30. echo jwt::create(1,12536630);
  31. }
  32. }