| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace backend\controllers;
- use biz\merchant\services\AdminService;
- use biz\platform\services\WxOpenService;
- use common\components\jwt;
- use common\services\xhAdminService;
- use common\components\util;
- use Yii;
- use common\components\stringUtil;
- /**
- * 登陆验证 shish 2019.11.23
- */
- class AuthController extends PublicController
- {
-
- //登陆并拿到token shish 2019.11.23
- public function actionLogin()
- {
- $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'];
- //来源
- $sourceId = WxOpenService::getSourceId();
- //获取token
- $token = jwt::get($sourceId, $adminId);
- util::success(['token' => $token]);
- }
- public function actionLogout()
- {
- xhAdminService::logout();
- echo 'ok';
- }
- }
|