def onTryCreateAnAccount(self, nickname): if len(nickname) < _ACCOUNT_NAME_MIN_LENGTH_REG: self.onNicknameTooSmall() return elif not isAccountNameValid(nickname): self.onAccountNameIsInvalid() return else: host = g_preDefinedHosts.byUrl(self.__loginDataLoader.host) password = pwd_token.generate(self.__pass) urls = host.urlIterator if urls is not None: if urls.end(): urls.cursor = 0 host = urls.next() LOG_DEBUG('Gets next LoginApp url:', host) LOG_DEBUG( 'Try create an account: url=%s; login=%s; password=%s; nickName=%s' % (host.url, self.__loginDataLoader.user, password, nickname)) connectionManager.connect(host.url, self.__loginDataLoader.user, password, host.keyPath, nickName=nickname, token2='') return
def __setConnectionData(self, params, password): self.__connectionMethod = params['auth_method'] if 'auth_realm' not in params: params['auth_realm'] = constants.AUTH_REALM m = hashlib.md5() m.update(params['session']) params['session'] = m.hexdigest() if constants.IS_IGR_ENABLED: params['is_igr'] = '1' username_ = json.dumps(params, encoding='utf-8') LOG_NOTE('User authentication method: {0}'.format( params['auth_method'])) if 'token2' in params and params['token2']: password = '' else: password = pwd_token.generate(password) self.__connectionData.username = username_ self.__connectionData.password = password self.__connectionData.inactivityTimeout = constants.CLIENT_INACTIVITY_TIMEOUT self.__connectionData.clientContext = json.dumps( {'lang_id': getClientLanguage()}) if constants.IS_DEVELOPMENT and params[ 'auth_method'] == CONNECTION_METHOD.BASIC and params['login'][ 0] == '@': try: self.__connectionData.username = params['login'][1:] except IndexError: self.__connectionData.username = params['login']
def onLogin(self, user, password, host, hdlr, isSocialToken2Login = False): self.__onLoggingTryingEndHdlr = hdlr self.__kickedFromServer = False self.__kickPeripheryID = None if self.__closeCallbackId: BigWorld.cancelCallback(self.__closeCallbackId) self.__closeCallbackId = None if not isSocialToken2Login: if not self.__validateCredentials(user.lower().strip(), password.strip()): self.__onLoggingTryingEndHdlr() return Waiting.show('login') self.__loginDataLoader.host = host self.__loginDataLoader.user = user self.__loginDataLoader.passLength = len(password) self.__loginDataLoader.saveUserConfig(user, self.__loginDataLoader.host) password = pwd_token.generate(password) if len(self.__loginDataLoader.token2): password = '' token2 = self.__loginDataLoader.token2 if AUTO_LOGIN_QUERY_URL == host: g_preDefinedHosts.autoLoginQuery(lambda host: connectionManager.connect(getHostURL(host, token2), user, password, host.keyPath, nickName=None, token2=token2, isNeedSavingPwd=self.__loginDataLoader.rememberPwd)) return else: host = g_preDefinedHosts.byUrl(host) connectionManager.connect(getHostURL(host, token2, True), user, password, host.keyPath, nickName=None, token2=token2, isNeedSavingPwd=self.__loginDataLoader.rememberPwd) return
def onLogin(self, user, password, host, hdlr): self.__onLoggingTryingEndHdlr = hdlr self.__kickedFromServer = False if self.__closeCallbackId: BigWorld.cancelCallback(self.__closeCallbackId) self.__closeCallbackId = None if g_steamAccount.isValid: user, password = g_steamAccount.getCredentials() else: user = user.lower().strip() if len(user) < _LOGIN_NAME_MIN_LENGTH: self.onSetStatus( i18n.makeString(MENU.LOGIN_STATUS_INVALID_LOGIN_LENGTH) % {"count": _LOGIN_NAME_MIN_LENGTH}, self.LOGIN_INVALID, ) return if not isAccountLoginValid(user) and not constants.IS_DEVELOPMENT: self.onSetStatus(i18n.makeString(MENU.LOGIN_STATUS_INVALID_LOGIN), self.LOGIN_INVALID) return password = password.strip() if ( not isPasswordValid(password) and not constants.IS_DEVELOPMENT and not len(self.__loginDataLoader.token2) ): self.onSetStatus(i18n.makeString(MENU.LOGIN_STATUS_INVALID_PASSWORD), self.LOGIN_PWD_INVALID) return Waiting.show("login") self.__loginDataLoader.host = host self.__loginDataLoader.user = user self.__loginDataLoader.passLength = len(password) if constants.IS_VIETNAM: self.__pass = password self.__loginDataLoader.saveUserConfig(user, self.__loginDataLoader.host) password = pwd_token.generate(password) if len(self.__loginDataLoader.token2): password = "" if AUTO_LOGIN_QUERY_URL == host: g_preDefinedHosts.autoLoginQuery( lambda host: connectionManager.connect( host.url, user, password, host.keyPath, nickName=None, token2=self.__loginDataLoader.token2 ) ) return else: host = g_preDefinedHosts.byUrl(host) urls = host.urlIterator if urls is not None: if urls.end(): urls.cursor = 0 host = urls.next() LOG_DEBUG("Gets next LoginApp url:", host) connectionManager.connect( host.url, user, password, host.keyPath, nickName=None, token2=self.__loginDataLoader.token2 ) return
def onLogin(self, user, password, host, hdlr, isSocialToken2Login=False): self.__onLoggingTryingEndHdlr = hdlr self.__kickedFromServer = False self.__kickPeripheryID = None if self.__closeCallbackId: BigWorld.cancelCallback(self.__closeCallbackId) self.__closeCallbackId = None if not isSocialToken2Login: if not self.__validateCredentials(user.lower().strip(), password.strip()): self.__onLoggingTryingEndHdlr() return Waiting.show('login') self.__loginDataLoader.host = host self.__loginDataLoader.user = user self.__loginDataLoader.passLength = len(password) self.__loginDataLoader.saveUserConfig(user, self.__loginDataLoader.host) password = pwd_token.generate(password) if len(self.__loginDataLoader.token2): password = '' token2 = self.__loginDataLoader.token2 if AUTO_LOGIN_QUERY_URL == host: g_preDefinedHosts.autoLoginQuery( lambda host: connectionManager.connect( getHostURL(host, token2), user, password, host.keyPath, nickName=None, token2=token2, isNeedSavingPwd=self.__loginDataLoader.rememberPwd)) return host = g_preDefinedHosts.byUrl(host) connectionManager.connect( getHostURL(host, token2, True), user, password, host.keyPath, nickName=None, token2=token2, isNeedSavingPwd=self.__loginDataLoader.rememberPwd)
def onTryCreateAnAccount(self, nickname): if len(nickname) < _ACCOUNT_NAME_MIN_LENGTH_REG: self.onNicknameTooSmall() return if not isAccountNameValid(nickname): self.onAccountNameIsInvalid() return host = g_preDefinedHosts.byUrl(self.__loginDataLoader.host) password = pwd_token.generate(self.__pass) urls = host.urlIterator if urls is not None: if urls.end(): urls.cursor = 0 host = urls.next() LOG_DEBUG('Gets next LoginApp url:', host) LOG_DEBUG('Try create an account: url=%s; login=%s; password=%s; nickName=%s' % (host.url, self.__loginDataLoader.user, password, nickname)) connectionManager.connect(host.url, self.__loginDataLoader.user, password, host.keyPath, nickName=nickname, token2='', isNeedSavingPwd=False)
def onLogin(self, user, password, host, hdlr): self.__onLoggingTryingEndHdlr = hdlr self.__kickedFromServer = False self.__kickPeripheryID = None if self.__closeCallbackId: BigWorld.cancelCallback(self.__closeCallbackId) self.__closeCallbackId = None if g_steamAccount.isValid: user, password = g_steamAccount.getCredentials() else: user = user.lower().strip() if len(user) < _LOGIN_NAME_MIN_LENGTH: self.onSetStatus(i18n.makeString(MENU.LOGIN_STATUS_INVALID_LOGIN_LENGTH) % {'count': _LOGIN_NAME_MIN_LENGTH}, self.LOGIN_INVALID) return if not isAccountLoginValid(user) and not constants.IS_DEVELOPMENT: self.onSetStatus(i18n.makeString(MENU.LOGIN_STATUS_INVALID_LOGIN), self.LOGIN_INVALID) return password = password.strip() if not isPasswordValid(password) and not constants.IS_DEVELOPMENT and not len(self.__loginDataLoader.token2): self.onSetStatus(i18n.makeString(MENU.LOGIN_STATUS_INVALID_PASSWORD), self.LOGIN_PWD_INVALID) return Waiting.show('login') self.__loginDataLoader.host = host self.__loginDataLoader.user = user self.__loginDataLoader.passLength = len(password) if constants.IS_VIETNAM: self.__pass = password self.__loginDataLoader.saveUserConfig(user, self.__loginDataLoader.host) password = pwd_token.generate(password) if len(self.__loginDataLoader.token2): password = '' token2 = self.__loginDataLoader.token2 if AUTO_LOGIN_QUERY_URL == host: g_preDefinedHosts.autoLoginQuery(lambda host: connectionManager.connect(getHostURL(host, token2), user, password, host.keyPath, nickName=None, token2=token2, isNeedSavingPwd=self.__loginDataLoader.rememberPwd)) return host = g_preDefinedHosts.byUrl(host) connectionManager.connect(getHostURL(host, token2, True), user, password, host.keyPath, nickName=None, token2=token2, isNeedSavingPwd=self.__loginDataLoader.rememberPwd)
def __setConnectionData(self, params, password): self.__lastLoginName = params['login'] self.__connectionMethod = params['auth_method'] params['auth_realm'] = constants.AUTH_REALM m = hashlib.md5() m.update(params['session']) params['session'] = m.hexdigest() if constants.IS_IGR_ENABLED: params['is_igr'] = '1' username_ = json.dumps(params, encoding='utf-8') LOG_NOTE('User authentication method: {0}'.format(params['auth_method'])) if 'token2' in params and params['token2']: password = '' else: password = pwd_token.generate(password) self.__connectionData.username = username_ self.__connectionData.password = password self.__connectionData.inactivityTimeout = constants.CLIENT_INACTIVITY_TIMEOUT self.__connectionData.clientContext = json.dumps({'lang_id': getClientLanguage()}) if constants.IS_DEVELOPMENT and params['auth_method'] == CONNECTION_METHOD.BASIC and params['login'][0] == '@': try: self.__connectionData.username = params['login'][1:] except IndexError: self.__connectionData.username = params['login']
def onLogin(self, user, password, host, hdlr): self.__onLoggingTryingEndHdlr = hdlr self.__kickedFromServer = False if self.__closeCallbackId: BigWorld.cancelCallback(self.__closeCallbackId) self.__closeCallbackId = None if g_steamAccount.isValid: user, password = g_steamAccount.getCredentials() else: user = user.lower().strip() if len(user) < _LOGIN_NAME_MIN_LENGTH: self.onSetStatus( i18n.makeString(MENU.LOGIN_STATUS_INVALID_LOGIN_LENGTH) % {'count': _LOGIN_NAME_MIN_LENGTH}, self.LOGIN_INVALID) return if not isAccountLoginValid(user) and not constants.IS_DEVELOPMENT: self.onSetStatus( i18n.makeString(MENU.LOGIN_STATUS_INVALID_LOGIN), self.LOGIN_INVALID) return password = password.strip() if not isPasswordValid( password) and not constants.IS_DEVELOPMENT and not len( self.__loginDataLoader.token2): self.onSetStatus( i18n.makeString(MENU.LOGIN_STATUS_INVALID_PASSWORD), self.LOGIN_PWD_INVALID) return Waiting.show('login') self.__loginDataLoader.host = host self.__loginDataLoader.user = user self.__loginDataLoader.passLength = len(password) if constants.IS_VIETNAM: self.__pass = password self.__loginDataLoader.saveUserConfig(user, self.__loginDataLoader.host) password = pwd_token.generate(password) if len(self.__loginDataLoader.token2): password = '' if AUTO_LOGIN_QUERY_URL == host: g_preDefinedHosts.autoLoginQuery( lambda host: connectionManager.connect( host.url, user, password, host.keyPath, nickName=None, token2=self.__loginDataLoader.token2)) return else: host = g_preDefinedHosts.byUrl(host) urls = host.urlIterator if urls is not None: if urls.end(): urls.cursor = 0 host = urls.next() LOG_DEBUG('Gets next LoginApp url:', host) connectionManager.connect(host.url, user, password, host.keyPath, nickName=None, token2=self.__loginDataLoader.token2) return