|
@@ -28,6 +28,10 @@ class webuserlogic extends baselogic
|
|
|
'sendsms' => [
|
|
|
['name' => 'telno', 'title' => '手机号', 'require' => true, 'type' => 'numeric'],
|
|
|
],
|
|
|
+ 'loginbypwd' => [
|
|
|
+ ['name' => 'account', 'title' => '账号', 'require' => true],
|
|
|
+ ['name' => 'passwd', 'title' => '密码', 'require' => true],
|
|
|
+ ],
|
|
|
];
|
|
|
return $list;
|
|
|
}
|
|
@@ -144,5 +148,72 @@ class webuserlogic extends baselogic
|
|
|
$result = $s_tc->sendsms($array);
|
|
|
return $result;
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 通过验证码登陆
|
|
|
+ *
|
|
|
+ * @param [type] $arr
|
|
|
+ * @return void
|
|
|
+ * @author wj
|
|
|
+ * @date 2022-08-18
|
|
|
+ */
|
|
|
+ public function loginbypwd($arr)
|
|
|
+ {
|
|
|
+ $result = $this->checkparam(__FUNCTION__, $arr);
|
|
|
+ if (1 != $result['status']) {
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+ $data = $result['data'];
|
|
|
+ $account = $data['account'];
|
|
|
+ $passwd = $data['passwd'];
|
|
|
+ //验证用户
|
|
|
+ $m_w = new webusermodel();
|
|
|
+ //手机号作为账户号
|
|
|
+ $winfo = $m_w->getinfobytelno($account);
|
|
|
+ if (empty($winfo)) {
|
|
|
+ return backarr(0, "无用户数据");
|
|
|
+ }
|
|
|
+ $wid = $winfo['id'];
|
|
|
+ $telno = $winfo['telno'];
|
|
|
+ $pwd = $winfo['userpwd'];
|
|
|
+ if (empty($pwd)) {
|
|
|
+ //密码为空设为默认
|
|
|
+ $pwd = $this->getpwd("000000");
|
|
|
+ $row = $m_w->setpwd($wid, $pwd);
|
|
|
+ if (empty($row)) {
|
|
|
+ return backarr(0, "密码修改失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //验证密码
|
|
|
+ if (!password_verify($passwd, $pwd)) {
|
|
|
+ return backarr(0, "密码错误");
|
|
|
+ }
|
|
|
+ //重置token
|
|
|
+ $row = $m_w->settoken($wid, $telno);
|
|
|
+ if (empty($row)) {
|
|
|
+ return backarr(0, "用户token修改失败");
|
|
|
+ }
|
|
|
+ $winfo = $m_w->getinfobyid($wid, ['token']);
|
|
|
+ return backarr(1, "用户登录成功", $winfo);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 获取加密后的密码
|
|
|
+ *
|
|
|
+ * @param string $salt
|
|
|
+ * @return void
|
|
|
+ * @author wj
|
|
|
+ * @date 2022-08-20
|
|
|
+ */
|
|
|
+ public function getpwd($pwd = "")
|
|
|
+ {
|
|
|
+ $defaultpwd = "000000";
|
|
|
+ if (empty($pwd) || !is_string($pwd)) {
|
|
|
+ $pwd = $defaultpwd;
|
|
|
+ }
|
|
|
+ $options = [
|
|
|
+ 'cost' => 12, //递归层数
|
|
|
+ ];
|
|
|
+ $pwd = password_hash($pwd, PASSWORD_DEFAULT, $options);
|
|
|
+ return $pwd;
|
|
|
+ }
|
|
|
|
|
|
}
|