def changeAccount(self): logOutAccount = g_loginManager.getPreference('login_type') g_loginManager.clearPreferences() g_loginManager.writePreferences() self.__lastLoginType = g_loginManager.getPreference('login_type') self._setData() self._showForm() self.as_setErrorMessageS(self.__getLogoutWarning(logOutAccount), INVALID_FIELDS.ALL_VALID)
def __doConnect(self): login, token2 = self.__credentials self.__addHandlers() connectionManager.initiateConnection({'login': login, 'token2': token2, 'auth_method': CONNECTION_METHOD.TOKEN2, 'session': BigWorld.wg_cpsalt(g_loginManager.getPreference('session')), 'temporary': str(int(not g_loginManager.getPreference('remember_user')))}, '', getHostURL(self.__host, token2))
def _setData(self): self._rememberUser = g_loginManager.getPreference('remember_user') if self._rememberUser: password = '******' * g_loginManager.getPreference('password_length') else: password = '' if GUI_SETTINGS.clearLoginValue: login = password = '' else: login = g_loginManager.getPreference('login') self.as_setDefaultValuesS(login, password, self._rememberUser, GUI_SETTINGS.rememberPassVisible, GUI_SETTINGS.igrCredentialsReset, not GUI_SETTINGS.isEmpty('recoveryPswdURL')) self.__updateServersList()
def isPwdInvalid(self, password): isInvalid = False if not constants.IS_DEVELOPMENT and not g_loginManager.getPreference( 'token2'): from external_strings_utils import isPasswordValid isInvalid = not isPasswordValid(password) return isInvalid
def isLoginInvalid(self, login): isInvalid = False if not constants.IS_DEVELOPMENT and not g_loginManager.getPreference( 'token2'): from external_strings_utils import isAccountLoginValid isInvalid = not isAccountLoginValid(login) return isInvalid
def __getLogoutWarning(socialNetworkName): localizationString = "#menu:login/social/warning/SOCIAL_NETWORK_LOGOUT" formatter = { "userName": g_loginManager.getPreference("name"), "socialNetworkLink": makeHtmlString( "html_templates:socialNetworkLogin", "socialNetworkLink", { "socialNetworkName": socialNetworkName, "socialNetworkOfficialName": _ms("#tooltips:login/social/" + socialNetworkName), }, ), } if socialNetworkName != SOCIAL_NETWORKS.WGNI: localizationString += "_BOTH" formatter["wargamingNetLink"] = makeHtmlString( "html_templates:socialNetworkLogin", "socialNetworkLink", { "socialNetworkName": SOCIAL_NETWORKS.WGNI, "socialNetworkOfficialName": _ms("#tooltips:login/social/" + SOCIAL_NETWORKS.WGNI), }, ) return makeHtmlString( "html_templates:socialNetworkLogin", "logoutWarning", {"warningMessage": _ms(localizationString) % formatter}, )
def __getLogoutWarning(socialNetworkName): localizationString = '#menu:login/social/warning/SOCIAL_NETWORK_LOGOUT' formatter = { 'userName': g_loginManager.getPreference('name'), 'socialNetworkLink': makeHtmlString( 'html_templates:socialNetworkLogin', 'socialNetworkLink', { 'socialNetworkName': socialNetworkName, 'socialNetworkOfficialName': _ms('#tooltips:login/social/' + socialNetworkName) }) } if socialNetworkName != SOCIAL_NETWORKS.WGNI: localizationString += '_BOTH' formatter['wargamingNetLink'] = makeHtmlString( 'html_templates:socialNetworkLogin', 'socialNetworkLink', { 'socialNetworkName': SOCIAL_NETWORKS.WGNI, 'socialNetworkOfficialName': _ms('#tooltips:login/social/' + SOCIAL_NETWORKS.WGNI) }) return makeHtmlString( 'html_templates:socialNetworkLogin', 'logoutWarning', {'warningMessage': _ms(localizationString) % formatter})
def __onLoggedOn(self, *args): """Event handler that sets an actual last login type. Last login type should be set at the very end instead of beginning in order to handle cases like choosing wrong social network, or misclicking on social network and then typing wrong password using basic login. """ self.__lastLoginType = g_loginManager.getPreference('login_type')
def __getLogoutWarning(socialNetworkName): localizationString = '#menu:login/social/warning/SOCIAL_NETWORK_LOGOUT' formatter = {'userName': g_loginManager.getPreference('name'), 'socialNetworkLink': makeHtmlString('html_templates:socialNetworkLogin', 'socialNetworkLink', {'socialNetworkName': socialNetworkName, 'socialNetworkOfficialName': _ms('#tooltips:login/social/' + socialNetworkName)})} if socialNetworkName != SOCIAL_NETWORKS.WGNI: localizationString += '_BOTH' formatter['wargamingNetLink'] = makeHtmlString('html_templates:socialNetworkLogin', 'socialNetworkLink', {'socialNetworkName': SOCIAL_NETWORKS.WGNI, 'socialNetworkOfficialName': _ms('#tooltips:login/social/' + SOCIAL_NETWORKS.WGNI)}) return makeHtmlString('html_templates:socialNetworkLogin', 'logoutWarning', {'warningMessage': _ms(localizationString) % formatter})
def _showForm(self): socialList = g_loginManager.getAvailableSocialNetworks() if self.__lastLoginType in socialList and self._rememberUser: self.as_showSocialFormS( len(g_loginManager.getPreference('token2')) != 0, self.__userName, makeHtmlString('html_templates:socialNetworkLogin', 'transparentLogo', {'socialNetwork': self.__lastLoginType}), self.__lastLoginType) else: self.as_showSimpleFormS(True, self.__setSocialDataList(socialList))
def _showForm(self): socialList = g_loginManager.getAvailableSocialNetworks() if self.__lastLoginType in socialList and self._rememberUser: self.as_showSocialFormS( len(g_loginManager.getPreference("token2")) != 0, self.__userName, makeHtmlString( "html_templates:socialNetworkLogin", "transparentLogo", {"socialNetwork": self.__lastLoginType} ), self.__lastLoginType, ) else: self.as_showSimpleFormS(True, self.__setSocialDataList(socialList))
def onLogin(self, userName, password, serverName, isSocialToken2Login): g_statistics.noteHangarLoadingState(HANGAR_LOADING_STATE.LOGIN, True) self._autoSearchVisited = serverName == AUTO_LOGIN_QUERY_URL self.__customLoginStatus = None result = self.__validateCredentials( userName.lower().strip(), password.strip(), bool(g_loginManager.getPreference('token2'))) if result.isValid: Waiting.show('login') g_loginManager.initiateLogin( userName, password, serverName, isSocialToken2Login, isSocialToken2Login or self._rememberUser) else: self.as_setErrorMessageS(result.errorMessage, result.invalidFields) return
def __init__(self, ctx = None): LoginView.__init__(self, ctx=ctx) self.__userName = g_loginManager.getPreference('name') self.__lastLoginType = g_loginManager.getPreference('login_type')
def isToken(self): return bool(g_loginManager.getPreference('token2'))
def __init__(self, ctx=None): LoginView.__init__(self, ctx=ctx) self.__userName = g_loginManager.getPreference('name') self.__lastLoginType = g_loginManager.getPreference('login_type')
def battleResultsCallback(self, arenaUniqueID, responseCode, value = None, revision = 0): if responseCode == AccountCommands.RES_NON_PLAYER or responseCode == AccountCommands.RES_COOLDOWN: BigWorld.callback(1.0, lambda: self.queue.put(arenaUniqueID)) self.battleResultsBusy.release() @!( 'return 1') return if responseCode < 0: self.battleResultsBusy.release() @!('return 2') return arenaTypeID = value['common']['arenaTypeID'] arenaType = ArenaType.g_cache[arenaTypeID] personal = value['personal'].itervalues().next() vehicleCompDesc = personal['typeCompDescr'] vt = vehiclesWG.getVehicleType(vehicleCompDesc) result = 1 if int(personal['team']) == int(value['common']['winnerTeam'])\ else (0 if not int(value['common']['winnerTeam']) else -1) place = 1 arenaUniqueID = value['arenaUniqueID'] squadsTier = {} vehicles = value['vehicles'] for vehicle in vehicles.values(): pTypeCompDescr = vehicle[0]['typeCompDescr'] if pTypeCompDescr is not None: pvt = vehiclesWG.getVehicleType(pTypeCompDescr) tier = pvt.level if set(vehiclesWG.VEHICLE_CLASS_TAGS.intersection(pvt.tags)).pop() == 'lightTank' and tier > 5: tier += 1 squadId = value['players'][vehicle[0]['accountDBID']]['prebattleID'] squadsTier[squadId] = max(squadsTier.get(squadId, 0), tier) if personal['team'] == vehicle[0]['team'] and \ personal['originalXP'] < vehicle[0]['xp']: place += 1 battleTier = 11 if max(squadsTier.values()) == 10 and min(squadsTier.values()) == 9 \ else max(squadsTier.values()) proceeds = personal['credits'] - personal['autoRepairCost'] -\ personal['autoEquipCost'][0] - personal['autoLoadCost'][0] tmenXP = personal['tmenXP'] if 'premium' in vt.tags: tmenXP = int(1.5*tmenXP) battle = { 'playerName': BigWorld.player().name, 'playerAccount': g_loginManager.getPreference('login'), 'idNum': vehicleCompDesc, 'map': arenaType.geometryName, 'vehicle': vt.name.replace(':', '-'), 'tier': vt.level, 'result': result, 'damage': personal['damageDealt'], 'frag': personal['kills'], 'spot': personal['spotted'], 'def': personal['droppedCapturePoints'], 'cap': personal['capturePoints'], 'shots': personal['shots'], 'hits': personal['directHits'], 'pierced': personal['piercings'], 'xp': personal['xp'], 'originalXP': personal['originalXP'], 'freeXP': personal['freeXP'], 'place': place, 'credits': proceeds, 'gold': personal['gold'] - personal['autoEquipCost'][1] - personal['autoLoadCost'][1], 'battleTier': battleTier, 'assist': personal['damageAssistedRadio'] + personal['damageAssistedTrack'], 'assistRadio': personal['damageAssistedRadio'], 'assistTrack': personal['damageAssistedTrack'] } extended = { 'vehicle': battle['vehicle'], 'map': battle['map'], 'result': result, 'autoRepair': personal['autoRepairCost'], 'autoEquip': personal['autoEquipCost'][0], 'autoLoad': personal['autoLoadCost'][0], 'tmenXP': tmenXP } @!( 'battle') @!( battle) @!( 'extended') @!( extended) self.save(battle) self.battleResultsBusy.release()
def isLoginInvalid(self, login): isInvalid = False if not constants.IS_DEVELOPMENT and not g_loginManager.getPreference('token2'): from external_strings_utils import isAccountLoginValid isInvalid = not isAccountLoginValid(login) return isInvalid
def isPwdInvalid(self, password): isInvalid = False if not constants.IS_DEVELOPMENT and not g_loginManager.getPreference('token2'): from external_strings_utils import isPasswordValid isInvalid = not isPasswordValid(password) return isInvalid
def onLogin(self, userName, password, serverName, isSocialToken2Login): g_statistics.noteHangarLoadingState(HANGAR_LOADING_STATE.LOGIN, True) self._autoSearchVisited = serverName == AUTO_LOGIN_QUERY_URL result = self.__validateCredentials(userName.lower().strip(), password.strip(), bool(g_loginManager.getPreference('token2'))) if result.isValid: Waiting.show('login') g_loginManager.initiateLogin(userName, password, serverName, isSocialToken2Login, isSocialToken2Login or self._rememberUser) else: self.as_setErrorMessageS(result.errorMessage, result.invalidFields)