Exemplo n.º 1
0
 public function resetpwdAction()
 {
     $request = $this->getRequest();
     $account = $request->get("account");
     $txtvaildcode = $request->get("txtvaildcode");
     $pwd = $request->get("txtnewpwd");
     $pwd_im = $pwd;
     $da = $this->get("we_data_access");
     $da_im = $this->get("we_data_access_im");
     $re = array("returncode" => ReturnCode::$SUCCESS);
     if (empty($account)) {
         return $this->responseJson(Utils::WrapResultError("帐号不能为空"), $request->get('jsoncallback'));
     }
     if (empty($txtvaildcode)) {
         return $this->responseJson(Utils::WrapResultError("验证码不能为空"), $request->get('jsoncallback'));
     }
     //验证帐号及验证码
     $isEmail = Utils::validateEmail($account);
     $isMobile = Utils::validateMobile($account);
     if (!$isEmail && !$isMobile) {
         return $this->responseJson(Utils::WrapResultError("帐号格式不正确,仅支持邮箱或手机帐号"), $request->get('jsoncallback'));
     }
     $u_staff = new \Justsy\BaseBundle\Management\Staff($da, $da_im, $account, $this->get('logger'), $this->container);
     $targetStaffInfo = $u_staff->getInfo();
     if (empty($targetStaffInfo)) {
         return $this->responseJson(Utils::WrapResultError("帐号无效"), $request->get('jsoncallback'));
     }
     $sysparam = new \Justsy\BaseBundle\DataAccess\SysParam($this->container);
     $wn_code = $sysparam->GetSysParam("mobile_active_code");
     if ($txtvaildcode != $wn_code) {
         $sql = "select * from we_mobilebind_validcode where login_account=? and actiontype='FP' and valid_date>now() order by valid_date desc limit 0,1";
         $ds = $da->GetData('t', $sql, array((string) $account));
         if ($txtvaildcode != $ds["t"]["rows"][0]["validcode"]) {
             return $this->responseJson(Utils::WrapResultError("验证码无效"), $request->get('jsoncallback'));
         }
     }
     try {
         $login_account = $targetStaffInfo['login_account'];
         $re = $u_staff->changepassword($login_account, $pwd, $this->get('security.encoder_factory'));
         return $this->responseJson($re, $request->get('jsoncallback'));
     } catch (Exception $e) {
         return $this->responseJson(Utils::WrapResultError("重置密码失败,请稍后重试"), $request->get('jsoncallback'));
     }
 }
Exemplo n.º 2
0
 public function updatePassByMobileAction(Request $request)
 {
     $login_account = $request->get("login_account");
     $pwd = $request->get("pwd");
     $active = $request->get("active_code");
     $result = array();
     $state = $this->checkLose($login_account, $active);
     if ($state == 2) {
         $result = array("succeed" => false, "err" => "短信验证码错误!");
     } else {
         if ($state == 0) {
             $result = array("succeed" => false, "err" => "短信验证码已过期!");
         } else {
             if ($state == 1) {
                 $da = $this->get('we_data_access');
                 $da_im = $this->get('we_data_access_im');
                 $pwdMgr = new \Justsy\BaseBundle\Management\Staff($da, $da_im, $login_account, $this->get("logger"), $this->container);
                 $factory = $this->container->get("security.encoder_factory");
                 $result = $pwdMgr->changepassword($login_account, $pwd, $factory);
                 $success = isset($result["returncode"]) ? $result["returncode"] : "9999";
                 if ($success == "0000") {
                     $sql = "update we_retrieve_password set valid='0' where id=? and login_account=?";
                     $da->ExecSQL($sql, array((string) $active, (string) $login_account));
                     $result = array("succeed" => true, "url" => $this->generateUrl('root'));
                 } else {
                     $result = array("succeed" => false, "err" => "修改密码失败");
                 }
             }
         }
     }
     $response = new Response(json_encode($result));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }