login: Remove account server cruft

This commit is contained in:
John Cote 2021-07-01 01:21:36 -04:00
parent 80362a1d25
commit acc1d7165b
13 changed files with 12 additions and 603 deletions

View file

@ -25,9 +25,7 @@ from direct.distributed.PyDatagram import PyDatagram
from direct.distributed.PyDatagramIterator import PyDatagramIterator from direct.distributed.PyDatagramIterator import PyDatagramIterator
from otp.avatar import Avatar from otp.avatar import Avatar
from otp.avatar.DistributedPlayer import DistributedPlayer from otp.avatar.DistributedPlayer import DistributedPlayer
from otp.login import TTAccount
from otp.login import LoginTTSpecificDevAccount from otp.login import LoginTTSpecificDevAccount
from otp.login import AccountServerConstants
from otp.login.CreateAccountScreen import CreateAccountScreen from otp.login.CreateAccountScreen import CreateAccountScreen
from otp.login import LoginScreen from otp.login import LoginScreen
from otp.otpgui import OTPDialog from otp.otpgui import OTPDialog
@ -495,13 +493,6 @@ class OTPClientRepository(ClientRepositoryBase):
self.gotoFirstScreen() self.gotoFirstScreen()
def gotoFirstScreen(self): def gotoFirstScreen(self):
try:
self.accountServerConstants = AccountServerConstants.AccountServerConstants(self)
except TTAccount.TTAccountException as e:
self.notify.debug(str(e))
self.loginFSM.request('failedToGetServerConstants', [e])
return
self.startReaderPollTask() self.startReaderPollTask()
if not __astron__: if not __astron__:
self.startHeartbeat() self.startHeartbeat()
@ -630,7 +621,7 @@ class OTPClientRepository(ClientRepositoryBase):
def enterFailedToGetServerConstants(self, e): def enterFailedToGetServerConstants(self, e):
self.handler = self.handleMessageType self.handler = self.handleMessageType
messenger.send('connectionIssue') messenger.send('connectionIssue')
url = AccountServerConstants.AccountServerConstants.getServerURL() url = 'N/A'
statusCode = 0 statusCode = 0
if isinstance(e, HTTPUtil.ConnectionError): if isinstance(e, HTTPUtil.ConnectionError):
statusCode = e.statusCode statusCode = e.statusCode
@ -1903,13 +1894,6 @@ class OTPClientRepository(ClientRepositoryBase):
render2d.prepareScene(gsg) render2d.prepareScene(gsg)
base.graphicsEngine.renderFrame() base.graphicsEngine.renderFrame()
def refreshAccountServerDate(self, forceRefresh = 0):
try:
self.accountServerDate.grabDate(force=forceRefresh)
except TTAccount.TTAccountException as e:
self.notify.debug(str(e))
return 1
def resetPeriodTimer(self, secondsRemaining): def resetPeriodTimer(self, secondsRemaining):
self.periodTimerExpired = 0 self.periodTimerExpired = 0
self.periodTimerSecondsRemaining = secondsRemaining self.periodTimerSecondsRemaining = secondsRemaining

View file

@ -4,9 +4,7 @@ import time
import builtins import builtins
from panda3d.core import * from panda3d.core import *
from direct.showbase import DConfig from direct.showbase import DConfig
from direct.showbase.MessengerGlobal import *
from direct.showbase.DirectObject import DirectObject from direct.showbase.DirectObject import DirectObject
from direct.showbase.EventManagerGlobal import *
from direct.task.MiniTask import MiniTaskManager from direct.task.MiniTask import MiniTaskManager
from direct.directnotify.DirectNotifyGlobal import * from direct.directnotify.DirectNotifyGlobal import *

View file

@ -1,67 +0,0 @@
from pandac.PandaModules import *
from .RemoteValueSet import *
from direct.directnotify import DirectNotifyGlobal
from . import TTAccount
from . import HTTPUtil
class AccountServerConstants(RemoteValueSet):
notify = DirectNotifyGlobal.directNotify.newCategory('AccountServerConstants')
def __init__(self, cr):
self.expectedConstants = ['minNameLength',
'minPwLength',
'allowNewAccounts',
'freeTrialPeriodInDays',
'priceFirstMonth',
'pricePerMonth',
'customerServicePhoneNumber',
'creditCardUpFront']
self.defaults = {'minNameLength': '1',
'minPwLength': '1',
'allowNewAccounts': '1',
'creditCardUpFront': '0',
'priceFirstMonth': '9.95',
'pricePerMonth': '9.95'}
noquery = 1
if cr.productName == 'DisneyOnline-US':
if base.config.GetBool('tt-specific-login', 0):
pass
else:
noquery = 0
if cr.accountOldAuth or base.config.GetBool('default-server-constants', noquery):
self.notify.debug('setting defaults, not using account server constants')
self.dict = {}
for constantName in self.expectedConstants:
self.dict[constantName] = 'DEFAULT'
self.dict.update(self.defaults)
return
url = URLSpec(AccountServerConstants.getServer())
url.setPath('/constants.php')
self.notify.debug('grabbing account server constants from %s' % url.cStr())
RemoteValueSet.__init__(self, url, cr.http, expectedHeader='ACCOUNT SERVER CONSTANTS', expectedFields=self.expectedConstants)
def getBool(self, name):
return self.__getConstant(name, RemoteValueSet.getBool)
def getInt(self, name):
return self.__getConstant(name, RemoteValueSet.getInt)
def getFloat(self, name):
return self.__getConstant(name, RemoteValueSet.getFloat)
def getString(self, name):
return self.__getConstant(name, RemoteValueSet.getString)
def __getConstant(self, constantName, accessor):
if constantName not in self.expectedConstants:
self.notify.warning("requested constant '%s' not in expected constant list; if it's a new constant, add it to the list" % constantName)
return accessor(self, constantName)
@staticmethod
def getServer():
return TTAccount.getAccountServer().cStr()
@staticmethod
def getServerURL():
return TTAccount.getAccountServer()

View file

@ -7,7 +7,6 @@ from direct.fsm import ClassicFSM
from direct.fsm import State from direct.fsm import State
from direct.directnotify import DirectNotifyGlobal from direct.directnotify import DirectNotifyGlobal
from otp.otpbase import OTPLocalizer from otp.otpbase import OTPLocalizer
from . import TTAccount
from . import GuiScreen from . import GuiScreen
from otp.otpbase import OTPGlobals from otp.otpbase import OTPGlobals
from direct.distributed.MsgTypes import * from direct.distributed.MsgTypes import *
@ -152,20 +151,11 @@ class CreateAccountScreen(StateData.StateData, GuiScreen.GuiScreen):
self.cr.handler = self.handleWaitForLoginResponse self.cr.handler = self.handleWaitForLoginResponse
self.cr.userName = self.userName self.cr.userName = self.userName
self.cr.password = self.password self.cr.password = self.password
try:
data = {} data = {}
referrer = launcher.getReferrerCode() referrer = launcher.getReferrerCode()
if referrer is not None: if referrer is not None:
data['referrer'] = referrer data['referrer'] = referrer
error = self.loginInterface.createAccount(self.userName, self.password, data) error = self.loginInterface.createAccount(self.userName, self.password, data)
except TTAccount.TTAccountException as e:
error = str(e)
self.notify.info(error)
self.dialog.setMessage(error + OTPLocalizer.CreateAccountScreenConnectionErrorSuffix)
self.dialog.show()
self.acceptOnce(self.dialogDoneEvent, self.__handleConnectionErrorAck)
return
if error: if error:
self.notify.info(error) self.notify.info(error)
self.dialog.setMessage(error) self.dialog.setMessage(error)

View file

@ -14,7 +14,6 @@ from otp.otpgui import OTPDialog
from otp.otpbase import OTPLocalizer from otp.otpbase import OTPLocalizer
from otp.otpbase import OTPGlobals from otp.otpbase import OTPGlobals
from otp.uberdog.AccountDetailRecord import AccountDetailRecord, SubDetailRecord from otp.uberdog.AccountDetailRecord import AccountDetailRecord, SubDetailRecord
from . import TTAccount
from . import GuiScreen from . import GuiScreen
class LoginScreen(StateData.StateData, GuiScreen.GuiScreen): class LoginScreen(StateData.StateData, GuiScreen.GuiScreen):
@ -199,12 +198,7 @@ class LoginScreen(StateData.StateData, GuiScreen.GuiScreen):
self.cr.handler = self.handleWaitForLoginResponse self.cr.handler = self.handleWaitForLoginResponse
self.cr.userName = self.userName self.cr.userName = self.userName
self.cr.password = self.password self.cr.password = self.password
try:
error = self.loginInterface.authorize(self.userName, self.password) error = self.loginInterface.authorize(self.userName, self.password)
except TTAccount.TTAccountException as e:
self.fsm.request('showConnectionProblemDialog', [str(e)])
return
if error: if error:
self.notify.info(error) self.notify.info(error)
freeTimeExpired = self.loginInterface.getErrorCode() == 10 freeTimeExpired = self.loginInterface.getErrorCode() == 10

View file

@ -2,16 +2,13 @@ from pandac.PandaModules import *
from direct.distributed.MsgTypes import * from direct.distributed.MsgTypes import *
from direct.directnotify import DirectNotifyGlobal from direct.directnotify import DirectNotifyGlobal
from . import LoginBase from . import LoginBase
from . import TTAccount
from .TTAccount import TTAccountException
from direct.distributed.PyDatagram import PyDatagram from direct.distributed.PyDatagram import PyDatagram
class LoginTTAccount(LoginBase.LoginBase, TTAccount.TTAccount): class LoginTTAccount(LoginBase.LoginBase):
notify = DirectNotifyGlobal.directNotify.newCategory('LoginTTAcct') notify = DirectNotifyGlobal.directNotify.newCategory('LoginTTAcct')
def __init__(self, cr): def __init__(self, cr):
LoginBase.LoginBase.__init__(self, cr) LoginBase.LoginBase.__init__(self, cr)
TTAccount.TTAccount.__init__(self, cr)
self.useTTSpecificLogin = base.config.GetBool('tt-specific-login', 0) self.useTTSpecificLogin = base.config.GetBool('tt-specific-login', 0)
self.notify.info('self.useTTSpecificLogin =%s' % self.useTTSpecificLogin) self.notify.info('self.useTTSpecificLogin =%s' % self.useTTSpecificLogin)
@ -59,53 +56,13 @@ class LoginTTAccount(LoginBase.LoginBase, TTAccount.TTAccount):
datagram.addInt32(CLIENT_LOGIN_2_PLAY_TOKEN) datagram.addInt32(CLIENT_LOGIN_2_PLAY_TOKEN)
def getErrorCode(self): def getErrorCode(self):
return self.response.getInt('errorCode', 0) return 0
def needToSetParentPassword(self): def needToSetParentPassword(self):
return self.response.getBool('secretsPasswordNotSet', 0) return 0
def authenticateParentPassword(self, loginName, password, parentPassword): def authenticateParentPassword(self, loginName, password, parentPassword):
if base.cr.withParentAccount: return True, None
self.notify.error('authenticateParentPassword called, but with parentAccount')
try:
errorMsg = self.talk('authenticateParentUsernameAndPassword', data=self.makeLoginDict(loginName, parentPassword))
if not errorMsg:
return (1, None)
if self.response.getInt('errorCode') in (5, 72):
return (0, None)
return (0, errorMsg)
except TTAccountException as e:
return (0, str(e))
elif self.useTTSpecificLogin:
try:
errorMsg = self.talk('authenticateParentPasswordNewStyle', data=self.makeLoginDict(loginName, parentPassword))
if not errorMsg:
return (1, None)
if self.response.getInt('errorCode') in (5, 72):
return (0, None)
return (0, errorMsg)
except TTAccountException as e:
return (0, str(e))
else:
return TTAccount.TTAccount.authenticateParentPassword(self, loginName, password, parentPassword)
return None
def authenticateDelete(self, loginName, password): def authenticateDelete(self, loginName, password):
if self.useTTSpecificLogin: return True, None
try:
errorMsg = self.talk('authenticateDeleteNewStyle', data=self.makeLoginDict(loginName, password))
if not errorMsg:
return (1, None)
if self.response.getInt('errorCode') in (5, 72):
return (0, None)
return (0, errorMsg)
except TTAccountException as e:
return (0, str(e))
else:
self.notify.info('using old style authenticate delete')
result = TTAccount.TTAccount.authenticateDelete(self, loginName, password)
return result
return None

View file

@ -3,7 +3,6 @@ from direct.distributed.MsgTypes import *
from direct.directnotify import DirectNotifyGlobal from direct.directnotify import DirectNotifyGlobal
from . import LoginTTAccount from . import LoginTTAccount
from direct.distributed.PyDatagram import PyDatagram from direct.distributed.PyDatagram import PyDatagram
from .TTAccount import TTAccountException
class LoginTTSpecificDevAccount(LoginTTAccount.LoginTTAccount): class LoginTTSpecificDevAccount(LoginTTAccount.LoginTTAccount):
notify = DirectNotifyGlobal.directNotify.newCategory('LoginTTSpecificDevAccount') notify = DirectNotifyGlobal.directNotify.newCategory('LoginTTSpecificDevAccount')

View file

@ -1,71 +0,0 @@
from direct.directnotify import DirectNotifyGlobal
from . import TTAccount
from . import HTTPUtil
class RemoteValueSet:
notify = DirectNotifyGlobal.directNotify.newCategory('RemoteValueSet')
def __init__(self, url, http, body = '', expectedHeader = None, expectedFields = [], onUnexpectedResponse = None):
if onUnexpectedResponse is None:
onUnexpectedResponse = self.__onUnexpectedResponse
response = HTTPUtil.getHTTPResponse(url, http, body)
if expectedHeader is not None:
if response[0] != expectedHeader:
errMsg = 'unexpected response: %s' % response
self.notify.warning(errMsg)
onUnexpectedResponse(errMsg)
return
response = response[1:]
self.dict = {}
for line in response:
if not len(line):
continue
try:
name, value = line.split('=', 1)
except ValueError as e:
errMsg = 'unexpected response: %s' % response
self.notify.warning(errMsg)
onUnexpectedResponse(errMsg)
return
if len(expectedFields):
if name not in expectedFields:
self.notify.warning("received field '%s' that is not in expected field list" % name)
self.dict[name] = value
for name in expectedFields:
if name not in self.dict:
errMsg = "missing expected field '%s'" % name
self.notify.warning(errMsg)
onUnexpectedResponse(errMsg)
return
return
def __repr__(self):
return 'RemoteValueSet:%s' % str(self.dict)
def hasKey(self, key):
return key in self.dict
def getBool(self, name, default = None):
return self.__getValue(name, lambda x: int(x) != 0, default)
def getInt(self, name, default = None):
return self.__getValue(name, int, default)
def getFloat(self, name, default = None):
return self.__getValue(name, float, default)
def getString(self, name, default = None):
return self.__getValue(name, str, default)
def __getValue(self, name, convOp, default):
if default is None:
return convOp(self.dict[name])
else:
return convOp(self.dict.get(name, default))
return
def __onUnexpectedResponse(self, errStr):
raise HTTPUtil.UnexpectedResponse(errStr)

View file

@ -1,280 +0,0 @@
from pandac.PandaModules import *
from pandac.PandaModules import *
from direct.directnotify import DirectNotifyGlobal
from direct.showbase import PythonUtil
from otp.otpbase import OTPLocalizer
from . import HTTPUtil
from . import RemoteValueSet
import copy
accountServer = ''
accountServer = launcher.getAccountServer()
print('TTAccount: accountServer from launcher: ', accountServer)
configAccountServer = base.config.GetString('account-server', '')
if configAccountServer:
accountServer = configAccountServer
print('TTAccount: overriding accountServer from config: ', accountServer)
if not accountServer:
accountServer = 'https://toontown.go.com'
print('TTAccount: default accountServer: ', accountServer)
accountServer = URLSpec(accountServer, 1)
def getAccountServer():
return accountServer
TTAccountException = HTTPUtil.HTTPUtilException
class TTAccount:
notify = DirectNotifyGlobal.directNotify.newCategory('TTAccount')
def __init__(self, cr):
self.cr = cr
self.response = None
return
def createAccount(self, loginName, password, data):
return self.talk('create', data=self.__makeLoginDict(loginName, password, data))
def authorize(self, loginName, password):
return self.talk('play', data=self.__makeLoginDict(loginName, password))
def createBilling(self, loginName, password, data):
return self.talk('purchase', data=self.__makeLoginDict(loginName, password, data))
def setParentPassword(self, loginName, password, parentPassword):
return self.talk('setParentPassword', data=self.__makeLoginDict(loginName, password, {'parentPassword': parentPassword}))
def supportsParentPassword(self):
return 1
def authenticateParentPassword(self, loginName, password, parentPassword):
try:
errorMsg = self.talk('authenticateParentPassword', data=self.__makeLoginDict(loginName, parentPassword))
if not errorMsg:
return (1, None)
if self.response.getInt('errorCode') in (5, 72):
return (0, None)
return (0, errorMsg)
except TTAccountException as e:
return (0, str(e))
return None
def supportsAuthenticateDelete(self):
return 1
def authenticateDelete(self, loginName, password):
try:
errorMsg = self.talk('authenticateDelete', data=self.__makeLoginDict(loginName, password))
if not errorMsg:
return (1, None)
if self.response.getInt('errorCode') in (5, 72):
return (0, None)
return (0, errorMsg)
except TTAccountException as e:
return (0, str(e))
return None
def enableSecretFriends(self, loginName, password, parentPassword, enable = 1):
try:
errorMsg = self.talk('setSecretChat', data=self.__makeLoginDict(loginName, parentPassword, {'chat': base.cr.secretChatAllowed,
'secretsNeedParentPassword': base.cr.secretChatNeedsParentPassword}))
if not errorMsg:
return (1, None)
if self.response.getInt('errorCode') in (5, 72):
return (0, None)
return (0, errorMsg)
except TTAccountException as e:
return (0, str(e))
return None
def changePassword(self, loginName, password, newPassword):
return self.talk('purchase', data=self.__makeLoginDict(loginName, password, {'newPassword': newPassword}))
def requestPwdReminder(self, email = None, acctName = None):
data = {}
if email is not None:
data['email'] = email
else:
data['accountName'] = acctName
return self.talk('forgotPassword', data)
def cancelAccount(self, loginName, password):
return self.talk('cancel', data=self.__makeLoginDict(loginName, password))
def getAccountData(self, loginName, password):
errorMsg = self.talk('get', data=self.__makeLoginDict(loginName, password))
if errorMsg:
self.notify.warning('getAccountData error: %s' % errorMsg)
return errorMsg
if self.response.hasKey('errorMsg'):
self.notify.warning("error field is: '%s'" % self.response.getString('errorMsg'))
self.accountData = copy.deepcopy(self.response)
fieldNameMap = {'em': 'email',
'l1': 'addr1',
'l2': 'addr2',
'l3': 'addr3'}
dict = self.accountData.dict
for fieldName in list(dict.keys()):
if fieldName in fieldNameMap:
dict[fieldNameMap[fieldName]] = dict[fieldName]
del dict[fieldName]
return None
def getLastErrorMsg(self, forceCustServNum = 0):
errCode = self.response.getInt('errorCode')
if errCode < 100:
msg = self.response.getString('errorMsg')
if forceCustServNum:
msg += ' ' + OTPLocalizer.TTAccountCustomerServiceHelp % self.cr.accountServerConstants.getString('customerServicePhoneNumber')
elif errCode < 200:
msg = self.response.getString('errorMsg')
msg += ' ' + OTPLocalizer.TTAccountCustomerServiceHelp % self.cr.accountServerConstants.getString('customerServicePhoneNumber')
elif errCode >= 500:
msg = OTPLocalizer.TTAccountIntractibleError
msg += ' ' + OTPLocalizer.TTAccountCallCustomerService % self.cr.accountServerConstants.getString('customerServicePhoneNumber')
else:
self.notify.warning('unknown error code class: %s: %s' % (self.response.getInt('errorCode'), self.response.getString('errorMsg')))
msg = self.response.getString('errorMsg')
msg += ' ' + OTPLocalizer.TTAccountCallCustomerService % self.cr.accountServerConstants.getString('customerServicePhoneNumber')
return msg
def __makeLoginDict(self, loginName, password, data = None):
dict = {'accountName': loginName,
'password': password}
if data:
dict.update(data)
return dict
def makeLoginDict(self, loginName, password, data = None):
return self.__makeLoginDict(loginName, password, data)
def talk(self, operation, data = {}):
self.notify.debug('TTAccount.talk()')
for key in list(data.keys()):
data[key] = str(data[key])
if operation in ('play', 'get', 'cancel', 'authenticateParentPassword', 'authenticateDelete', 'authenticateParentPasswordNewStyle', 'authenticateDeleteNewStyle'):
pass
elif operation == 'authenticateParentUsernameAndPassword':
pass
elif operation == 'forgotPassword':
pass
elif operation == 'setParentPassword':
pass
elif operation == 'setSecretChat':
pass
elif operation == 'create':
pass
elif operation == 'purchase':
if 'newPassword' in data:
pass
else:
self.notify.error("Internal TTAccount error: need to add 'required data' checking for %s operation" % operation)
op2Php = {'play': 'play',
'get': 'get',
'cancel': 'cancel',
'create': 'create',
'purchase': 'purchase',
'setParentPassword': 'setSecrets',
'authenticateParentPassword': 'authenticateChat',
'authenticateDelete': 'authDelete',
'setSecretChat': 'setChat',
'forgotPassword': 'forgotPw',
'authenticateParentPasswordNewStyle': 'api/authChat',
'authenticateParentUsernameAndPassword': 'api/authParentChat',
'authenticateDeleteNewStyle': 'api/authDelete'}
newWebOperations = ('authenticateParentPasswordNewStyle', 'authenticateParentUsernameAndPassword', 'authenticateDeleteNewStyle')
url = URLSpec(getAccountServer())
if operation in newWebOperations:
url.setPath('/%s' % op2Php[operation])
else:
url.setPath('/%s.php' % op2Php[operation])
body = ''
if 'accountName' in data:
if operation not in newWebOperations:
url.setQuery('n=%s' % URLSpec.quote(data['accountName']))
serverFields = {'accountName': 'n',
'password': 'p',
'parentPassword': 'sp',
'newPassword': 'np',
'chat': 'chat',
'email': 'em',
'dobYear': 'doby',
'dobMonth': 'dobm',
'dobDay': 'dobd',
'ccNumber': 'ccn',
'ccMonth': 'ccm',
'ccYear': 'ccy',
'nameOnCard': 'noc',
'addr1': 'l1',
'addr2': 'l2',
'addr3': 'l3',
'city': 'city',
'state': 'state',
'country': 'country',
'zip': 'zip',
'referrer': 'ref',
'secretsNeedParentPassword': 'secretsNeedsParentPassword',
'parentPasswordNewStyle': 'pp',
'parentUsername': 'pu',
'userid': 'userid'}
ignoredFields = ('ccType',)
outBoundFields = {}
for fieldName in list(data.keys()):
if fieldName not in serverFields:
if fieldName not in ignoredFields:
self.notify.error('unknown data field: %s' % fieldName)
else:
outBoundFields[serverFields[fieldName]] = data[fieldName]
orderedFields = list(outBoundFields.keys())
orderedFields.sort()
for fieldName in orderedFields:
if len(body):
body += '&'
body += '%s=%s' % (fieldName, URLSpec.quotePlus(outBoundFields[fieldName]))
self.notify.debug('url=' + url.cStr())
self.notify.debug('body=' + body)
if operation in ('get',):
expectedHeader = 'ACCOUNT INFO'
elif operation in ('play', 'cancel', 'create', 'purchase', 'setParentPassword', 'setSecretChat', 'authenticateParentPassword', 'authenticateDelete', 'forgotPassword', 'authenticateParentPasswordNewStyle', 'authenticateParentUsernameAndPassword', 'authenticateDeleteNewStyle'):
expectedHeader = 'ACCOUNT SERVER RESPONSE'
else:
self.notify.error("Internal TTAccount error: need to set expected response header for '%s' operation" % operation)
self.response = RemoteValueSet.RemoteValueSet(url, self.cr.http, body=body, expectedHeader=expectedHeader)
self.notify.debug(' self.response=' + str(self.response))
if self.response.hasKey('errorCode'):
errorCode = self.response.getInt('errorCode')
self.notify.info('account server error code: %s' % errorCode)
if errorCode == 10:
self.cr.freeTimeExpiresAt = 0
if self.response.hasKey('errorMsg'):
return self.getLastErrorMsg()
if operation in ('get', 'forgotPassword', 'authenticateDelete', 'play', 'cancel', 'create', 'purchase', 'setParentPassword', 'authenticateParentPassword', 'authenticateParentPasswordNewStyle', 'authenticateParentUsernameAndPassword', 'authenticateDeleteNewStyle'):
pass
elif operation == 'setSecretChat':
self.playToken = self.response.getString('playToken')
self.playTokenIsEncrypted = 1
else:
self.notify.error('Internal TTAccount error: need to extract useful data for %s operation' % operation)
return None
def authenticateParentUsernameAndPassword(self, loginName, password, parentUsername, parentPassword):
try:
errorMsg = self.talk('authenticateParentUsernameAndPassword', data=self.__makeLoginDict(loginName, password, {'parentUsername': parentUsername,
'parentPasswordNewStyle': parentPassword,
'userid': loginName}))
if not errorMsg:
return (1, None)
if self.response.getInt('errorCode') in (5, 72):
return (0, None)
return (0, errorMsg)
except TTAccountException as e:
return (0, str(e))
return None

View file

@ -16,8 +16,6 @@ from direct.showbase.InputStateGlobal import inputState
from otp.avatar import Avatar from otp.avatar import Avatar
from otp.avatar import DistributedAvatar from otp.avatar import DistributedAvatar
from otp.friends import FriendManager from otp.friends import FriendManager
from otp.login import TTAccount
from otp.login import AccountServerConstants
from otp.login import LoginScreen from otp.login import LoginScreen
from otp.login import LoginGSAccount from otp.login import LoginGSAccount
from otp.login import LoginGoAccount from otp.login import LoginGoAccount
@ -43,7 +41,6 @@ from toontown.friends import FriendsListPanel
from toontown.friends import ToontownFriendSecret from toontown.friends import ToontownFriendSecret
from toontown.uberdog import TTSpeedchatRelay from toontown.uberdog import TTSpeedchatRelay
from toontown.login import DateObject from toontown.login import DateObject
from toontown.login import AccountServerDate
from toontown.login import AvatarChooser from toontown.login import AvatarChooser
from toontown.makeatoon import MakeAToon from toontown.makeatoon import MakeAToon
from toontown.pets import DistributedPet, PetDetail, PetHandle from toontown.pets import DistributedPet, PetDetail, PetHandle
@ -117,7 +114,6 @@ class ToontownClientRepository(OTPClientRepository.OTPClientRepository):
self.elderFriendsMap = {} self.elderFriendsMap = {}
self.__queryAvatarMap = {} self.__queryAvatarMap = {}
self.dateObject = DateObject.DateObject() self.dateObject = DateObject.DateObject()
self.accountServerDate = AccountServerDate.AccountServerDate()
self.hoodMgr = HoodMgr.HoodMgr(self) self.hoodMgr = HoodMgr.HoodMgr(self)
self.setZonesEmulated = 0 self.setZonesEmulated = 0
self.old_setzone_interest_handle = None self.old_setzone_interest_handle = None

View file

@ -1,15 +1,5 @@
import sys
import os import os
import time
import string
import bz2
import random
from direct.showbase.MessengerGlobal import *
from direct.showbase.DirectObject import DirectObject
from direct.showbase.EventManagerGlobal import * from direct.showbase.EventManagerGlobal import *
from direct.task.TaskManagerGlobal import *
from direct.task.Task import Task
from direct.directnotify.DirectNotifyGlobal import *
from pandac.PandaModules import * from pandac.PandaModules import *
from otp.launcher.LauncherBase import LauncherBase from otp.launcher.LauncherBase import LauncherBase
from toontown.toonbase import TTLocalizer from toontown.toonbase import TTLocalizer
@ -79,9 +69,6 @@ class QuickLauncher(LauncherBase):
return value return value
def getAccountServer(self):
return self.getValue('ACCOUNT_SERVER', '')
def getGame2Done(self): def getGame2Done(self):
return True return True

View file

@ -1,57 +0,0 @@
from pandac.PandaModules import *
from otp.login.HTTPUtil import *
from direct.directnotify import DirectNotifyGlobal
from otp.login import TTAccount
from . import DateObject
from . import TTDateObject
import time
class AccountServerDate:
notify = DirectNotifyGlobal.directNotify.newCategory('AccountServerDate')
def __init__(self):
self.__grabbed = 0
def getServer(self):
return TTAccount.getAccountServer().cStr()
def grabDate(self, force = 0):
if self.__grabbed and not force:
self.notify.debug('using cached account server date')
return
if base.cr.accountOldAuth or base.config.GetBool('use-local-date', 0):
self.__useLocalClock()
return
url = URLSpec(self.getServer())
url.setPath('/getDate.php')
self.notify.debug('grabbing account server date from %s' % url.cStr())
response = getHTTPResponse(url, http)
if response[0] != 'ACCOUNT SERVER DATE':
self.notify.debug('invalid response header')
raise UnexpectedResponse('unexpected response, response=%s' % response)
try:
epoch = int(response[1])
except ValueError as e:
self.notify.debug(str(e))
raise UnexpectedResponse('unexpected response, response=%s' % response)
timeTuple = time.gmtime(epoch)
self.year = timeTuple[0]
self.month = timeTuple[1]
self.day = timeTuple[2]
base.cr.dateObject = TTDateObject.TTDateObject(self)
self.__grabbed = 1
def __useLocalClock(self):
self.month = base.cr.dateObject.getMonth()
self.year = base.cr.dateObject.getYear()
self.day = base.cr.dateObject.getDay()
def getMonth(self):
return self.month
def getYear(self):
return self.year
def getDay(self):
return self.day

View file

@ -1,21 +0,0 @@
from . import DateObject
class TTDateObject(DateObject.DateObject):
def __init__(self, accountServerDate):
self.accountServerDate = accountServerDate
def getYear(self):
return self.accountServerDate.getYear()
def getMonth(self):
return self.accountServerDate.getMonth()
def getDay(self):
return self.accountServerDate.getDay()
def getDetailedAge(self, dobMonth, dobYear, dobDay = None, curMonth = None, curYear = None, curDay = None):
return DateObject.DateObject.getDetailedAge(self, dobMonth, dobYear, dobDay, curMonth=self.getMonth(), curYear=self.getYear(), curDay=self.getDay())
def getAge(self, dobMonth, dobYear, dobDay = None, curMonth = None, curYear = None, curDay = None):
return TTDateObject.getDetailedAge(self, dobMonth, dobYear, dobDay=dobDay, curMonth=curMonth, curYear=curYear, curDay=curDay)[0]