...
|
...
|
@@ -130,24 +130,24 @@ class Index extends Backend |
|
|
}
|
|
|
if ($this->request->isPost()) {
|
|
|
$url = $this->request->get('url', 'index/forget');
|
|
|
$email = $this->request->post('email');
|
|
|
$mobile = $this->request->post('mobile');
|
|
|
$rule = [
|
|
|
'email' => 'require|email',
|
|
|
'mobile' => 'require',
|
|
|
// '__token__' => 'require|token',
|
|
|
];
|
|
|
$data = [
|
|
|
'email' => $email,
|
|
|
'mobile' => $mobile,
|
|
|
// '__token__' => $token,
|
|
|
];
|
|
|
$validate = new Validate($rule, [], ['email' => __('email')]);
|
|
|
$validate = new Validate($rule, [], ['mobile' => __('mobile')]);
|
|
|
$result = $validate->check($data);
|
|
|
if (!$result) {
|
|
|
$this->error($validate->getError(), $url, ['token' => $this->request->token()]);
|
|
|
}
|
|
|
//根据email获取商户信息
|
|
|
$admin = Db::name('admin')->where(['email'=>$email])->find();
|
|
|
//根据mobile获取商户信息
|
|
|
$admin = Db::name('admin')->where(['mobile'=>$mobile])->find();
|
|
|
if(empty($admin)){
|
|
|
$this->error('当前email尚未绑定');
|
|
|
$this->error('当前手机号尚未绑定');
|
|
|
}
|
|
|
if(empty($admin['user_id'])){
|
|
|
$this->error('平台管理员忘记密码请联系总管理员');
|
...
|
...
|
@@ -158,12 +158,12 @@ class Index extends Backend |
|
|
//生成验证码
|
|
|
$code = generateCode(6);
|
|
|
//储存验证码
|
|
|
$admin_code = Db::name('admin_code')->where(['email'=>$email])->find();
|
|
|
$admin_code = Db::name('admin_code')->where(['mobile'=>$mobile])->find();
|
|
|
$arr['code'] = $code;
|
|
|
$arr['pasttime'] = time()+600;
|
|
|
$arr['is_use'] = 0;
|
|
|
if(empty($admin_code)){
|
|
|
$arr['email'] = $email;
|
|
|
$arr['mobile'] = $mobile;
|
|
|
$arr['createtime'] = time();
|
|
|
$result1 = Db::name('admin_code')->insert($arr);
|
|
|
}else{
|
...
|
...
|
@@ -173,13 +173,17 @@ class Index extends Backend |
|
|
if(empty($result1)){
|
|
|
$this->error('sql执行失败');
|
|
|
}
|
|
|
//发送验证码
|
|
|
$this->send_ems($admin['email'],$code);
|
|
|
if ($result) {
|
|
|
$this->success('发送成功');
|
|
|
} else {
|
|
|
$content = array(
|
|
|
'content' => "【工品达】您的验证码是:" . $code . ",请于10分钟内使用,如非本人操作,可忽略此消息。",//短信内容
|
|
|
'mobile' => $mobile,//手机号码
|
|
|
'tKey' => time(),
|
|
|
);
|
|
|
$result2 = json_decode(send_sms2($content),true);
|
|
|
if ($result2['code'] != 200) {
|
|
|
Db::rollback();
|
|
|
$this->error('发送失败');
|
|
|
}
|
|
|
$this->success('发送成功');
|
|
|
/*AdminLog::setTitle(__('Login'));
|
|
|
$result = $this->auth->login($username, $password, $keeplogin ? 86400 : 0);
|
|
|
if ($result === true) {
|
...
|
...
|
@@ -199,7 +203,7 @@ class Index extends Backend |
|
|
return $this->view->fetch();
|
|
|
}
|
|
|
|
|
|
public function send_ems($receiver,$code){
|
|
|
/*public function send_ems($receiver,$code){
|
|
|
\think\Config::set('site', \think\Config::get('site'));
|
|
|
$email = new Email();
|
|
|
$str = "验证码:$code,10分钟内有效。";
|
...
|
...
|
@@ -209,7 +213,7 @@ class Index extends Backend |
|
|
->message($str)
|
|
|
->send();
|
|
|
return $result;
|
|
|
}
|
|
|
}*/
|
|
|
|
|
|
/**
|
|
|
* 验证验证码是否正确
|
...
|
...
|
@@ -217,24 +221,24 @@ class Index extends Backend |
|
|
public function verify_code(){
|
|
|
if ($this->request->isPost()) {
|
|
|
$url = $this->request->get('url', 'index/forget');
|
|
|
$email = $this->request->post('email');
|
|
|
$mobile = $this->request->post('mobile');
|
|
|
$code = $this->request->post('code');
|
|
|
$rule = [
|
|
|
'email' => 'require|email',
|
|
|
'mobile' => 'require',
|
|
|
'code' => 'require',
|
|
|
// '__token__' => 'require|token',
|
|
|
];
|
|
|
$data = [
|
|
|
'email' => $email,
|
|
|
'mobile' => $mobile,
|
|
|
'code' => $code,
|
|
|
// '__token__' => $token,
|
|
|
];
|
|
|
$validate = new Validate($rule, [], ['email' => __('email'), 'code' => '请输入验证码']);
|
|
|
$validate = new Validate($rule, [], ['mobile' => __('mobile'), 'code' => '请输入验证码']);
|
|
|
$result = $validate->check($data);
|
|
|
if (!$result) {
|
|
|
$this->error($validate->getError(), $url, ['token' => $this->request->token()]);
|
|
|
}
|
|
|
$admin_code = Db::name('admin_code')->where(['email'=>$email])->find();
|
|
|
$admin_code = Db::name('admin_code')->where(['mobile'=>$mobile])->find();
|
|
|
if(empty($admin_code)){
|
|
|
$this->error('404');
|
|
|
}
|
...
|
...
|
@@ -254,8 +258,8 @@ class Index extends Backend |
|
|
//生成令牌(为了安全)
|
|
|
$str = "Bronet";
|
|
|
$auth_code = config('auth_code');
|
|
|
$token = rawurlencode(sha1(md5($str.$auth_code).md5($email)));
|
|
|
$this->success('验证通过',url('reset_password',['token'=>$token,'email'=>$email],false,true));
|
|
|
$token = rawurlencode(sha1(md5($str.$auth_code).md5($mobile)));
|
|
|
$this->success('验证通过',url('reset_password',['token'=>$token,'email'=>$mobile],false,true));
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -270,21 +274,21 @@ class Index extends Backend |
|
|
if($this->request->isPost()){
|
|
|
$password = $this->request->param('password');
|
|
|
$affirm_password = $this->request->param('affirm_password');
|
|
|
$email = $this->request->param('email');
|
|
|
$mobile = $this->request->param('mobile');
|
|
|
$token = $this->request->param('token');
|
|
|
$rule = [
|
|
|
'password' => 'require|length:3,30',
|
|
|
'affirm_password' => 'require|length:3,30',
|
|
|
'email' => 'require|email',
|
|
|
'mobile' => 'require',
|
|
|
'token' => 'require',
|
|
|
];
|
|
|
$data = [
|
|
|
'password' => $password,
|
|
|
'affirm_password' => $affirm_password,
|
|
|
'email' => $email,
|
|
|
'mobile' => $mobile,
|
|
|
'token' => $token,
|
|
|
];
|
|
|
$validate = new Validate($rule, [], ['password' => __('password'), 'affirm_password' => __('Password'), 'email' => __('email')]);
|
|
|
$validate = new Validate($rule, [], ['password' => __('password'), 'affirm_password' => __('Password'), 'mobile' => __('mobile')]);
|
|
|
$result = $validate->check($data);
|
|
|
if (!$result) {
|
|
|
$this->error($validate->getError(), $url, ['token' => $this->request->token()]);
|
...
|
...
|
@@ -294,11 +298,11 @@ class Index extends Backend |
|
|
}
|
|
|
$str = "Bronet";
|
|
|
$auth_code = config('auth_code');
|
|
|
$token2 = rawurlencode(sha1(md5($str.$auth_code).md5($email)));
|
|
|
$token2 = rawurlencode(sha1(md5($str.$auth_code).md5($mobile)));
|
|
|
if($token != $token2){
|
|
|
$this->error('令牌错误','','','');
|
|
|
}
|
|
|
$admin = Db::name('admin')->where(['email'=>$email])->find();
|
|
|
$admin = Db::name('admin')->where(['email'=>$mobile])->find();
|
|
|
$password = md5(md5($password) . $admin['salt']);
|
|
|
$result = Db::name('admin')->where(['id'=>$admin['id']])->update(['password'=>$password]);
|
|
|
if(empty($result)){
|
...
|
...
|
@@ -308,10 +312,10 @@ class Index extends Backend |
|
|
$this->success('重置成功',$url);
|
|
|
}else{
|
|
|
$token = $this->request->param('token');
|
|
|
$email = $this->request->param('email');
|
|
|
$mobile = $this->request->param('mobile');
|
|
|
$str = "Bronet";
|
|
|
$auth_code = config('auth_code');
|
|
|
$token2 = rawurlencode(sha1(md5($str.$auth_code).md5($email)));
|
|
|
$token2 = rawurlencode(sha1(md5($str.$auth_code).md5($mobile)));
|
|
|
if($token != $token2){
|
|
|
$this->error('令牌错误','','','');
|
|
|
}
|
...
|
...
|
|