memory (params): fixes bugs in setParam:

- symbol 'd' was accessed without having been initialized when setting the empty value to a password which is not the profile password
    - the method was actually returning without waiting for the parameter to be set
This commit is contained in:
souliane 2014-05-21 21:14:40 +02:00
commit ea05b4e0d6

View file

@ -756,7 +756,8 @@ class Params(object):
if type_ == "button":
log.debug("Clicked param button %s" % node.toxml())
return defer.succeed(None)
elif type_ == "password":
d = defer.succeed(value)
if type_ == "password":
try:
personal_key = self.host.memory.auth_sessions.profileGetUnique(profile)[C.MEMORY_CRYPTO_KEY]
except TypeError:
@ -770,17 +771,16 @@ class Params(object):
d = PasswordHasher.hash(value) # profile password is hashed (empty value stays empty)
elif value: # other non empty passwords are encrypted with the personal key
d = BlockCipher.encrypt(personal_key, value)
else:
d = defer.succeed(value)
def gotFinalValue(value):
if self.host.isConnected(profile): # key can not exists if profile is not connected
self.params[profile][(category, name)] = value
self.host.bridge.paramUpdate(name, value, category, profile)
self.host.trigger.point("paramUpdateTrigger", name, value, category, node[0], profile)
d_list.append(self.storage.setIndParam(category, name, value, profile))
return self.storage.setIndParam(category, name, value, profile)
d.addCallback(gotFinalValue)
d_list.append(d)
return defer.DeferredList(d_list).addCallback(lambda dummy: None)
def _getNodesOfTypes(self, attr_type, node_type="@ALL@"):