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)
|
||||
value = str(min(max(int(value), min_), max_))
|
||||
|
||||
|
||||
log.info(_("Setting parameter (%(category)s, %(name)s) = %(value)s") %
|
||||
{'category': category, 'name': name, 'value': value if type_ != 'password' else '********'})
|
||||
|
||||
|
|
@ -842,36 +843,37 @@ class Params(object):
|
|||
assert node[0] == C.INDIVIDUAL
|
||||
assert profile_key != C.PROF_KEY_NONE
|
||||
|
||||
d_list = []
|
||||
if type_ == "button":
|
||||
log.debug(u"Clicked param button %s" % node.toxml())
|
||||
return defer.succeed(None)
|
||||
d = defer.succeed(value)
|
||||
if type_ == "password":
|
||||
elif type_ == "password":
|
||||
try:
|
||||
personal_key = self.host.memory.auth_sessions.profileGetUnique(profile)[C.MEMORY_CRYPTO_KEY]
|
||||
except TypeError:
|
||||
raise exceptions.InternalError(_('Trying to encrypt a password while the personal key is undefined!'))
|
||||
if (category, name) == C.PROFILE_PASS_PATH:
|
||||
# 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,
|
||||
data_value=personal_key,
|
||||
crypto_key=value,
|
||||
profile=profile))
|
||||
d = PasswordHasher.hash(value) # profile password is hashed (empty value stays empty)
|
||||
d = self.host.memory.encryptPersonalData(data_key=C.MEMORY_CRYPTO_KEY,
|
||||
data_value=personal_key,
|
||||
crypto_key=value,
|
||||
profile=profile)
|
||||
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
|
||||
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
|
||||
if self.host.memory.isSessionStarted(profile):
|
||||
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)
|
||||
return self.storage.setIndParam(category, name, value, profile)
|
||||
self.host.bridge.paramUpdate(name, value, category, profile)
|
||||
self.host.trigger.point("paramUpdateTrigger", name, value, category, node[0], profile)
|
||||
return self.storage.setIndParam(category, name, value, profile)
|
||||
else:
|
||||
raise exceptions.ProfileNotConnected
|
||||
|
||||
d.addCallback(gotFinalValue)
|
||||
d_list.append(d)
|
||||
return defer.DeferredList(d_list).addCallback(lambda dummy: None)
|
||||
return d
|
||||
|
||||
def _getNodesOfTypes(self, attr_type, node_type="@ALL@"):
|
||||
"""Return all the nodes matching the given types.
|
||||
|
|
|
|||
Loading…
Reference in a new issue