|
|
@@ -0,0 +1,37 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace saas\controllers;
|
|
|
+
|
|
|
+use biz\saas\services\StaffService;
|
|
|
+use common\components\jwt;
|
|
|
+use common\components\stringUtil;
|
|
|
+use common\components\util;
|
|
|
+use Yii;
|
|
|
+
|
|
|
+class StaffController extends BaseController
|
|
|
+{
|
|
|
+
|
|
|
+ public function actionLogin()
|
|
|
+ {
|
|
|
+ //登陆并拿到token shish 2019.11.23
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $mobile = isset($get['mobile']) ? $get['mobile'] : 0;
|
|
|
+ if (stringUtil::isMobile($mobile) == false) {
|
|
|
+ util::fail('请填写正常的手机号');
|
|
|
+ }
|
|
|
+ $password = isset($get['password']) && !empty($get['password']) ? $get['password'] : '';
|
|
|
+ if (empty($password)) {
|
|
|
+ util::fail('请输入密码');
|
|
|
+ }
|
|
|
+
|
|
|
+ $staff = StaffService::getByCondition(['mobile' => $mobile]);
|
|
|
+ if (password_verify($password, $staff['password']) == false) {
|
|
|
+ util::fail('密码错误');
|
|
|
+ }
|
|
|
+ $staffId = $staff['id'];
|
|
|
+ //获取token
|
|
|
+ $token = jwt::getNewToken($staffId);
|
|
|
+ util::success(['token' => $token]);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|