|
|
@@ -83,13 +83,16 @@ class PublicController extends AdminBaseController
|
|
|
}
|
|
|
|
|
|
$captcha = $this->request->param('captcha');
|
|
|
- if (empty($captcha)) {
|
|
|
- $this->error(lang('CAPTCHA_REQUIRED'));
|
|
|
- }
|
|
|
+ $code = $this->request->param('code');
|
|
|
+
|
|
|
|
|
|
$name = $this->request->param("username");
|
|
|
+ $mobile = $this->request->param("mobile");
|
|
|
$loginType = input('loginType', 1);
|
|
|
if ($loginType == 1) {
|
|
|
+ if (empty($captcha)) {
|
|
|
+ $this->error(lang('CAPTCHA_REQUIRED'));
|
|
|
+ }
|
|
|
|
|
|
//验证码
|
|
|
if (!cmf_captcha_check($captcha)) {
|
|
|
@@ -109,16 +112,20 @@ class PublicController extends AdminBaseController
|
|
|
$where['user_login'] = $name;
|
|
|
}
|
|
|
} else {
|
|
|
- $result = Sms::checkCode($name, $captcha,'admin');
|
|
|
+ if (empty($code)) {
|
|
|
+ $this->error(lang('CAPTCHA_REQUIRED'));
|
|
|
+ }
|
|
|
+
|
|
|
+ $result = Sms::checkCode($mobile, $code,'admin');
|
|
|
if ($result !== true) {
|
|
|
$this->error(lang($result));
|
|
|
}
|
|
|
|
|
|
- if (empty($name)) {
|
|
|
+ if (empty($mobile)) {
|
|
|
$this->error('请填写正确格式手机号码');
|
|
|
}
|
|
|
|
|
|
- $where['mobile'] = $name;
|
|
|
+ $where['mobile'] = $mobile;
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -126,22 +133,24 @@ class PublicController extends AdminBaseController
|
|
|
$result = Db::name('user')->where($where)->find();
|
|
|
if (!empty($result) && ($result['user_type'] == 1 || $result['user_type'] == 3)) {
|
|
|
|
|
|
- // 登录IP来源验证
|
|
|
- $ip = get_client_ip();
|
|
|
- if ($result['check_ip']) {
|
|
|
- $blackList = explode(',', $result['check_ip']);
|
|
|
- if ($blackList && !in_array($ip, $blackList)) {
|
|
|
- $this->error(lang('USER_IP_LIMIT'), '', $ip);
|
|
|
- }
|
|
|
- } else if ($result['user_type'] != 3) {
|
|
|
- $blackList = config('app.ipBlackList');
|
|
|
- if ($blackList && !preg_match($blackList, $ip)) {
|
|
|
- $this->error(lang('USER_IP_LIMIT'), '', $ip);
|
|
|
+ if($loginType == 1){
|
|
|
+ // 登录IP来源验证
|
|
|
+ $ip = get_client_ip();
|
|
|
+ if ($result['check_ip']) {
|
|
|
+ $blackList = explode(',', $result['check_ip']);
|
|
|
+ if ($blackList && !in_array($ip, $blackList)) {
|
|
|
+ $this->error(lang('USER_IP_LIMIT'), '', $ip);
|
|
|
+ }
|
|
|
+ } else if ($result['user_type'] != 3) {
|
|
|
+ $blackList = config('app.ipBlackList');
|
|
|
+ if ($blackList && !preg_match($blackList, $ip)) {
|
|
|
+ $this->error(lang('USER_IP_LIMIT'), '', $ip);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if ($loginType == 1 && !cmf_compare_password($pass, $result['user_pass'])) {
|
|
|
- $this->error(lang('PASSWORD_NOT_RIGHT'));
|
|
|
+ if (!cmf_compare_password($pass, $result['user_pass'])) {
|
|
|
+ $this->error(lang('PASSWORD_NOT_RIGHT'));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
$groups = Db::name('RoleUser')
|
|
|
@@ -185,7 +194,7 @@ class PublicController extends AdminBaseController
|
|
|
// 发送处理
|
|
|
$result = Sms::sendCode($mobile, ['tpName' => 'code'], 'admin');
|
|
|
if (!is_array($result)) {
|
|
|
- $this->error(is_numeric($result) ? $result : 1009);
|
|
|
+ $this->error(lang(is_numeric($result) ? $result : 1009));
|
|
|
}
|
|
|
|
|
|
$this->success('验证码发送成功');
|