|
@@ -210,6 +210,63 @@ class Auth extends BaseController
|
|
|
return view("",['msg' => $msg, 'ep' => $ep]);
|
|
|
}
|
|
|
|
|
|
+ public function findBackPassword(){
|
|
|
+ $type = intval($this->request['type']);
|
|
|
+ if(\StrUtil::isEmpOrNull($type)){
|
|
|
+ return json(['msg' => '请选择账号类型','code' => 500]);
|
|
|
+ }
|
|
|
+ $username = \StrUtil::getRequestDecodeParam($this->request,'username');
|
|
|
+ if(\StrUtil::isEmpOrNull($username)){
|
|
|
+ return json(['msg' => '请填写账号','code' => 500]);
|
|
|
+ }
|
|
|
+ $password = \StrUtil::getRequestDecodeParam($this->request,'password');
|
|
|
+ if(\StrUtil::isEmpOrNull($password)){
|
|
|
+ return json(['msg' => '请填写新密码','code' => 500]);
|
|
|
+ }
|
|
|
+ $rePassword = \StrUtil::getRequestDecodeParam($this->request,'rePassword');
|
|
|
+ if(\StrUtil::isEmpOrNull($rePassword)){
|
|
|
+ return json(['msg' => '请填写重复新密码','code' => 500]);
|
|
|
+ }
|
|
|
+ if($password != $rePassword){
|
|
|
+ return json(['msg' => '两次密码填写不一致','code' => 500]);
|
|
|
+ }
|
|
|
+ if(!preg_match("/^(?=.*\d)(?=.*[A-Za-z]).{8,}$/",$password)){
|
|
|
+ return json(['msg' => '密码必须包含字母、数字、特殊字符且长度超过8位','code' => 500]);
|
|
|
+ }
|
|
|
+ $phone = \StrUtil::getRequestDecodeParam($this->request,'phone');
|
|
|
+ if(\StrUtil::isEmpOrNull($phone)){
|
|
|
+ return json(['msg' => '请填写手机号','code' => 500]);
|
|
|
+ }
|
|
|
+ $verificationCode = \StrUtil::getRequestDecodeParam($this->request,'verificationCode');
|
|
|
+ if(\StrUtil::isEmpOrNull($verificationCode)){
|
|
|
+ return json(['msg' => '请填写验证码','code' => 500]);
|
|
|
+ }
|
|
|
+ //检验验证码
|
|
|
+ $codeResult = MessageRecord::where('smsType',1)->where('phone',$phone)->order('createTime','desc')->find();
|
|
|
+ if(!$codeResult || (time() - strtotime($codeResult['sendingDate']) > 300) ){
|
|
|
+ return json(['msg' => '请先发送验证码','code' => 500]);
|
|
|
+ }
|
|
|
+ if($codeResult['params'] != $verificationCode){
|
|
|
+ return json(['msg' => '验证码不正确','code' => 500]);
|
|
|
+ }
|
|
|
+ $password = hash('md5',$password);
|
|
|
+ if($type == 1){
|
|
|
+ $count = \app\common\model\Enterprise::where('username',$username)->where('agentPhone',$phone)->count();
|
|
|
+ if($count == 0){
|
|
|
+ return json(['msg' => '未找到相关账号,请仔细核对账号及手机号信息!','code' => 500]);
|
|
|
+ }
|
|
|
+ if($count > 1){
|
|
|
+ return json(['msg' => '找到多个账户,请联系相关单位处理!','code' => 500]);
|
|
|
+ }
|
|
|
+ $ep = \app\common\model\Enterprise::where('username',$username)->where('agentPhone',$phone)->find();
|
|
|
+ $ep->password = $password;
|
|
|
+ $ep->save();
|
|
|
+ }else{
|
|
|
+ //个人账户找回密码TODO
|
|
|
+ }
|
|
|
+ return json(['msg' => '找回密码成功!','code' => 200]);
|
|
|
+ }
|
|
|
+
|
|
|
public function verificationCode()
|
|
|
{
|
|
|
$phone = $this->request["phone"];
|