AuthController.php 997 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace backend\controllers;
  3. use biz\merchant\services\AdminService;
  4. use biz\platform\services\WxOpenService;
  5. use common\components\jwt;
  6. use common\components\util;
  7. use Yii;
  8. use common\components\stringUtil;
  9. /**
  10. * 登陆验证 shish 2019.11.23
  11. */
  12. class AuthController extends PublicController
  13. {
  14. //登陆并拿到token shish 2019.11.23
  15. public function actionLogin()
  16. {
  17. $get = Yii::$app->request->get();
  18. $mobile = isset($get['mobile']) ? $get['mobile'] : 0;
  19. if (stringUtil::isMobieNumber($mobile) == false) {
  20. util::fail('请填写正常的手机号');
  21. }
  22. $password = isset($get['password']) && !empty($get['password']) ? $get['password'] : '';
  23. if (empty($password)) {
  24. util::fail('请输入密码');
  25. }
  26. $admin = AdminService::getByCondition(['mobile' => $mobile]);
  27. if ($admin['password'] != md5($password)) {
  28. util::fail('密码错误');
  29. }
  30. $adminId = $admin['id'];
  31. //获取token
  32. $token = jwt::get($adminId);
  33. util::success(['token' => $token]);
  34. }
  35. }