12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace backend\controllers;
- use backend\forms\AuthForm;
- use yii\helpers\ArrayHelper;
- use Yii;
- class AuthController extends BaseController
- {
- /**
- * behaviors
- * @return array
- */
- public function behaviors()
- {
- return ArrayHelper::merge(parent::behaviors(), [
- 'verbs' => [
- 'class' => \yii\filters\VerbFilter::className(),
- 'actions' => [
- 'token' => ['POST'],
- ],
- ],
- ]);
- }
- /**
- * 获取accessToken
- * @author: libingke
- */
- public function actionToken()
- {
- $model = new AuthForm();
- $model->setScenario('access_token');
- $model->load(['AuthForm' => Yii::$app->request->post()]);
- $data = [];
- if ($model->validate()) {
- $data = $model->getAccessToken();
- } else {
- $model->handleError();
- }
- return [
- 'code' => 200,
- 'message' => Yii::t('error', 200),
- 'data' => $data
- ];
- }
- }
|