/** * 第三方登录完成注册 */ public function thirdReg() { $post = I('post.'); $post['uname'] = I('post.uname'); if (!is_email($post['uname'])) { $this->error('用户名必须为邮箱!'); } $is_user = M('User')->where(array('uname' => $post['uname']))->count(); if ($is_user > 0) { $this->error("该邮箱已经被注册了"); } $post['nickname'] = I('post.nickname'); $post['upassword'] = I('post.password'); if (empty($post['upassword'])) { $this->error('请输入您的密码!'); } if (false == isMin($post['upassword'], 6)) { $this->error('密码不能小于6位!'); } $pwd = I('post.password2'); if ($post['upassword'] != $pwd) { $this->error("两次输入的密码不一致"); } $info = $this->userDb->token(false)->create($post); if ($info) { $userid = service('Passport')->userRegister($info['uname'], $info['upassword']); if ($userid > 0) { //获取用户信息 $memberinfo = service("Passport")->getLocalUser((int) $userid); $info['uname'] = $memberinfo['uname']; $info['upassword'] = $memberinfo['upassword']; $info['logtimes'] = 1; $info['login_time'] = time(); $info['lastip'] = get_client_ip(); $info['openkey'] = $post['openkey']; $info['openuid'] = C('BEGIN_UID') + $userid; $info['type'] = $post['type']; $info['islock'] = false; if (is_email($info['uname'])) { $info['uemail'] = $info['uname']; } elseif (is_mobile($info['uname'])) { $info['umobile'] = $info['uname']; } //保存为本地头像 /*$uploadPath='f/user/'.date('y').'/'.date('m').'/'.date('d'); if (!is_dir($uploadPath)) { mkdir($uploadPath,0777,true); } $img = file_get_contents($post['uavatar']); $fileName = 'uavatar_'.$memberinfo['userid'] .'.jpg'; $file = $uploadPath.'/' . $fileName; file_put_contents($file, $img); $info['uavatar']='/'.$file;*/ //新注册用户积分 $info['upoint'] = $this->userConfig['defualtupoint'] ? $this->userConfig['defualtupoint'] : 20; if (false !== $this->userDb->where(array('userid' => $memberinfo['userid']))->save($info)) { //获取积分 service('Passport')->userDynamic($this->userid, 20, '注册获取20个积分', 1, 'register'); //注册登陆状态 service("Passport")->loginLocal($post['uname'], $post['upassword']); $this->success("登录成功,正转向个人中心!", U('Index/index')); } else { //删除 service("Passport")->userDelete($memberinfo['userid']); $this->error("登录失败!"); } } else { $this->error(service("Passport")->getError() ?: '登录失败!'); } } else { $this->error($this->userDb->getError() ?: '登录失败!'); } }
public function repwd() { if ($_POST) { $post = I('post.'); $oldpwd = $post['oldpwd']; $newpwd = $post['newpwd']; $newpwd2 = $post['newpwd2']; $vcode = $post['vCode']; if (empty($oldpwd)) { $this->error("请输入旧密码"); } if (empty($newpwd)) { $this->error("请输入新密码"); } if (empty($newpwd2)) { $this->error("请输入确认密码"); } if ($newpwd != $newpwd2) { $this->error("输入的两次新密码不一致"); } if ($oldpwd == $newpwd) { $this->error("输入的旧密码与新密码不能一样"); } if (false == $this->verify($vcode, 'userpwd')) { $this->error('验证码错误,请重新输入!'); } if (false == isMin($newpwd, 6)) { $this->error('输入的新密码不能小于6位!'); } $user = M('User')->where(array('userid' => $this->userid))->field("uname, upassword, authkey")->find(); if (empty($user)) { $this->error("系统错误"); } $temp_pwd = D("User/User")->encryption($user['uname'], $oldpwd, $user['authkey']); if ($temp_pwd != $user['upassword']) { $this->error("输入的旧密码错误"); } $res = D('User/User')->ChangePassword($user['uname'], $newpwd); if ($res) { $this->success("修改成功", "/user/index/logout"); } else { $this->error("修改失败"); } //$encrypt = genRandomString(6); } else { $this->display(); } }