| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- namespace admin\controllers;
- use biz\admin\services\AdminService;
- use common\components\httpUtil;
- use common\components\jwt;
- use common\components\util;
- use Yii;
- use yii\web\Controller;
- use common\components\stringUtil;
- /**
- * 用户登陆
- */
- class AuthController extends PublicController
- {
-
- //登陆并拿到token shish 2019.11.23
- public function actionLogin()
- {
- httpUtil::getSourceId();die;
- $get = Yii::$app->request->get();
- $mobile = isset($get['mobile']) ? $get['mobile'] : 0;
- if (stringUtil::isMobieNumber($mobile) == false) {
- util::fail('请填写正常的手机号');
- }
- $password = isset($get['password']) && !empty($get['password']) ? $get['password'] : '';
- if (empty($password)) {
- util::fail('请输入密码');
- }
- $admin = AdminService::getByCondition(['mobile' => $mobile]);
- if ($admin['password'] != md5($password)) {
- util::fail('密码错误');
- }
- $adminId = $admin['id'];
- //获取token
- $token = jwt::getNewToken($adminId);
- util::success(['token' => $token]);
- }
-
- }
|