profile (params): fixed password setting: if profile was not connected, set was silently ignored
This commit is contained in:
parent
c0f53629e5
commit
c58da8d413
1 changed files with 16 additions and 14 deletions
|
|
@ -827,6 +827,7 @@ class Params(object):
|
||||||
raise exceptions.InternalError("Invalid integer parameter constraint: %s" % constraint)
|
raise exceptions.InternalError("Invalid integer parameter constraint: %s" % constraint)
|
||||||
value = str(min(max(int(value), min_), max_))
|
value = str(min(max(int(value), min_), max_))
|
||||||
|
|
||||||
|
|
||||||
log.info(_("Setting parameter (%(category)s, %(name)s) = %(value)s") %
|
log.info(_("Setting parameter (%(category)s, %(name)s) = %(value)s") %
|
||||||
{'category': category, 'name': name, 'value': value if type_ != 'password' else '********'})
|
{'category': category, 'name': name, 'value': value if type_ != 'password' else '********'})
|
||||||
|
|
||||||
|
|
@ -842,36 +843,37 @@ class Params(object):
|
||||||
assert node[0] == C.INDIVIDUAL
|
assert node[0] == C.INDIVIDUAL
|
||||||
assert profile_key != C.PROF_KEY_NONE
|
assert profile_key != C.PROF_KEY_NONE
|
||||||
|
|
||||||
d_list = []
|
|
||||||
if type_ == "button":
|
if type_ == "button":
|
||||||
log.debug(u"Clicked param button %s" % node.toxml())
|
log.debug(u"Clicked param button %s" % node.toxml())
|
||||||
return defer.succeed(None)
|
return defer.succeed(None)
|
||||||
d = defer.succeed(value)
|
elif type_ == "password":
|
||||||
if type_ == "password":
|
|
||||||
try:
|
try:
|
||||||
personal_key = self.host.memory.auth_sessions.profileGetUnique(profile)[C.MEMORY_CRYPTO_KEY]
|
personal_key = self.host.memory.auth_sessions.profileGetUnique(profile)[C.MEMORY_CRYPTO_KEY]
|
||||||
except TypeError:
|
except TypeError:
|
||||||
raise exceptions.InternalError(_('Trying to encrypt a password while the personal key is undefined!'))
|
raise exceptions.InternalError(_('Trying to encrypt a password while the personal key is undefined!'))
|
||||||
if (category, name) == C.PROFILE_PASS_PATH:
|
if (category, name) == C.PROFILE_PASS_PATH:
|
||||||
# using 'value' as the encryption key to encrypt another encryption key... could be confusing!
|
# using 'value' as the encryption key to encrypt another encryption key... could be confusing!
|
||||||
d_list.append(self.host.memory.encryptPersonalData(data_key=C.MEMORY_CRYPTO_KEY,
|
d = self.host.memory.encryptPersonalData(data_key=C.MEMORY_CRYPTO_KEY,
|
||||||
data_value=personal_key,
|
data_value=personal_key,
|
||||||
crypto_key=value,
|
crypto_key=value,
|
||||||
profile=profile))
|
profile=profile)
|
||||||
d = PasswordHasher.hash(value) # profile password is hashed (empty value stays empty)
|
d.addCallback(lambda dummy: PasswordHasher.hash(value)) # profile password is hashed (empty value stays empty)
|
||||||
elif value: # other non empty passwords are encrypted with the personal key
|
elif value: # other non empty passwords are encrypted with the personal key
|
||||||
d = BlockCipher.encrypt(personal_key, value)
|
d = BlockCipher.encrypt(personal_key, value)
|
||||||
|
else:
|
||||||
|
d = defer.succeed(value)
|
||||||
|
|
||||||
def gotFinalValue(value):
|
def gotFinalValue(value):
|
||||||
if self.host.isConnected(profile): # key can not exists if profile is not connected
|
if self.host.memory.isSessionStarted(profile):
|
||||||
self.params[profile][(category, name)] = value
|
self.params[profile][(category, name)] = value
|
||||||
self.host.bridge.paramUpdate(name, value, category, profile)
|
self.host.bridge.paramUpdate(name, value, category, profile)
|
||||||
self.host.trigger.point("paramUpdateTrigger", name, value, category, node[0], profile)
|
self.host.trigger.point("paramUpdateTrigger", name, value, category, node[0], profile)
|
||||||
return self.storage.setIndParam(category, name, value, profile)
|
return self.storage.setIndParam(category, name, value, profile)
|
||||||
|
else:
|
||||||
|
raise exceptions.ProfileNotConnected
|
||||||
|
|
||||||
d.addCallback(gotFinalValue)
|
d.addCallback(gotFinalValue)
|
||||||
d_list.append(d)
|
return d
|
||||||
return defer.DeferredList(d_list).addCallback(lambda dummy: None)
|
|
||||||
|
|
||||||
def _getNodesOfTypes(self, attr_type, node_type="@ALL@"):
|
def _getNodesOfTypes(self, attr_type, node_type="@ALL@"):
|
||||||
"""Return all the nodes matching the given types.
|
"""Return all the nodes matching the given types.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue