public function execute($request) { if ($request->format == 'json') { $user = Sp_Account_User::current(); $userid = $user->id; $row = Sp_Account_User::getUser($userid); $old = $request->old; $password = $request->password; $confirming = $request->confirming; $patternPasswd = Sp_Dictionary::getOtherOption('patternPasswd'); if (false == preg_match($patternPasswd, $old)) { return array('status' => '-122', 'msg' => '密码格式不正确'); } if (false == preg_match($patternPasswd, $confirming)) { return array('status' => '-122', 'msg' => '密码格式不正确'); } if (false == preg_match($patternPasswd, $password)) { return array('status' => '-122', 'msg' => '密码格式不正确'); } // 旧密码 if (!$this->checkOldPassword($old, $row)) { return array('status' => '-1', 'msg' => '旧密码不正确'); } if ($password != $confirming) { return array('status' => '-2', 'msg' => '两次密码不一致'); } $newpwd = Sp_Account_User::encrypt($password, $row['kid']); Sp_Account_Info::updatePassword($userid, $newpwd); return array('status' => '0', 'msg' => '密码修改成功'); } }