Exemplo n.º 1
0
 public function resetPassword($verify, $new_password)
 {
     //检验校验码是否正确
     $mobile = getMobileFromSession();
     if (!$mobile) {
         $this->apiError(903, "未发送短信验证码");
     }
     $tianyi = new TianyiAddon();
     if (!$tianyi->checkVerify($mobile, $verify)) {
         $this->apiError(803, "校验码错误");
     }
     //根据手机号查询UID
     $uid = $this->api->getUidByMobile($mobile);
     if (!$uid) {
         $this->apiError(902, "该手机尚未绑定任何帐号");
     }
     //设置新密码
     $result = $this->updateUser($uid, array('password' => $new_password));
     if (!$result) {
         $this->apiError(901, "更新用户信息失败:" . $this->api->getError());
     }
     // TODO: 清除已登录的SESSION,强制重新登录
     //返回成功信息
     $this->apiSuccess("密码修改成功");
 }
Exemplo n.º 2
0
 public function unbindMobile($verify)
 {
     $uid = $this->getUid();
     clean_query_user_cache($uid, 'mobile');
     $this->requireLogin();
     //确认用户已经绑定手机
     $model = D('User/UcenterMember');
     $user = $model->where(array('id' => $this->getUid()))->find();
     if (!$user['mobile']) {
         $this->apiError(1901, "您尚未绑定手机");
     }
     //确认被验证的手机号码与用户绑定的手机号相符
     $mobile = getMobileFromSession();
     if ($mobile != $user['mobile']) {
         $this->apiError(1902, "验证的手机与绑定的手机不符合");
     }
     //确认验证码正确
     $addon = new TianyiAddon();
     if (!$addon->checkVerify($mobile, $verify)) {
         $this->apiError(1903, "手机验证码错误");
     }
     //写入数据库
     $model->where(array('uid' => $uid))->save(array('mobile' => ''));
     //返回成功结果
     $this->apiSuccess("解绑成功");
 }