comparison src/stdui/ui_profile_manager.py @ 1313:a8d7500090f6 frontends_multi_profiles

core: boolConst is used to convert a boolean value to its equivalent string constant
author Goffi <goffi@goffi.org>
date Mon, 09 Feb 2015 21:39:47 +0100
parents cfd636203e8f
children 069ad98b360d
comparison
equal deleted inserted replaced
1309:d0d5ba3b4d64 1313:a8d7500090f6
46 @return: deferred dict 46 @return: deferred dict
47 """ 47 """
48 def gotProfileCipher(profile_cipher): 48 def gotProfileCipher(profile_cipher):
49 if self.host.memory.auth_sessions.profileGetUnique(profile): 49 if self.host.memory.auth_sessions.profileGetUnique(profile):
50 # case 1: profile already authenticated 50 # case 1: profile already authenticated
51 return {'validated': C.str(True)} 51 return {'validated': C.boolConst(True)}
52 self.profile_ciphers[profile] = profile_cipher 52 self.profile_ciphers[profile] = profile_cipher
53 if 'profile_password' in data: 53 if 'profile_password' in data:
54 # case 2: password is provided by the caller 54 # case 2: password is provided by the caller
55 return self._verifyPassword(data, profile) 55 return self._verifyPassword(data, profile)
56 56
79 return d 79 return d
80 80
81 def getParamError(self, failure): 81 def getParamError(self, failure):
82 _dialog = xml_tools.XMLUI('popup', title=D_('Error')) 82 _dialog = xml_tools.XMLUI('popup', title=D_('Error'))
83 _dialog.addText(D_("Can't get profile parameter.")) 83 _dialog.addText(D_("Can't get profile parameter."))
84 return {'xmlui': _dialog.toXml(), 'validated': C.str(False)} 84 return {'xmlui': _dialog.toXml(), 'validated': C.boolConst(False)}
85 85
86 @defer.inlineCallbacks 86 @defer.inlineCallbacks
87 def _verifyPassword(self, data, profile): 87 def _verifyPassword(self, data, profile):
88 """Verify the given password 88 """Verify the given password
89 89
99 profile_password = data['profile_password'] # not received from a user input 99 profile_password = data['profile_password'] # not received from a user input
100 verified = yield PasswordHasher.verify(profile_password, self.profile_ciphers[profile]) 100 verified = yield PasswordHasher.verify(profile_password, self.profile_ciphers[profile])
101 if not verified: 101 if not verified:
102 _dialog = xml_tools.XMLUI('popup', title=D_('Connection error')) 102 _dialog = xml_tools.XMLUI('popup', title=D_('Connection error'))
103 _dialog.addText(D_("The provided profile password doesn't match.")) 103 _dialog.addText(D_("The provided profile password doesn't match."))
104 defer.returnValue({'xmlui': _dialog.toXml(), 'validated': C.str(False)}) 104 defer.returnValue({'xmlui': _dialog.toXml(), 'validated': C.boolConst(False)})
105 105
106 yield self.host.memory.newAuthSession(profile_password, profile) 106 yield self.host.memory.newAuthSession(profile_password, profile)
107 defer.returnValue({'validated': C.str(True)}) 107 defer.returnValue({'validated': C.boolConst(True)})
108 108
109 def _changeXMPPPassword(self, data, profile): 109 def _changeXMPPPassword(self, data, profile):
110 session_data = self._sessions.profileGetUnique(profile) 110 session_data = self._sessions.profileGetUnique(profile)
111 if not session_data: 111 if not session_data:
112 server = self.host.memory.getParamA(C.FORCE_SERVER_PARAM, "Connection", profile_key=profile) 112 server = self.host.memory.getParamA(C.FORCE_SERVER_PARAM, "Connection", profile_key=profile)