# HG changeset patch # User souliane # Date 1448301075 -3600 # Node ID fd7f41d8cbdf323e1599f931856d3ffbdc887bc2 # Parent 5c1d6efd693609c57a461eb24bc96a088fbf527e memory: fixes asyncCreateProfile to not overwrite the personal key diff -r 5c1d6efd6936 -r fd7f41d8cbdf src/memory/memory.py --- a/src/memory/memory.py Mon Nov 23 17:50:23 2015 +0100 +++ b/src/memory/memory.py Mon Nov 23 18:51:15 2015 +0100 @@ -453,9 +453,15 @@ raise ValueError("Empty profile name") if name[0] == '@': raise ValueError("A profile name can't start with a '@'") - personal_key = BlockCipher.getRandomKey(base64=True) # generated once for all and saved in a PersistentDict - self.auth_sessions.newSession({C.MEMORY_CRYPTO_KEY: personal_key}, profile=name) # will be encrypted by setParam + d = self.params.asyncCreateProfile(name) + + def initPersonalKey(dummy): + # be sure to call this after checking that the profile doesn't exist yet + personal_key = BlockCipher.getRandomKey(base64=True) # generated once for all and saved in a PersistentDict + self.auth_sessions.newSession({C.MEMORY_CRYPTO_KEY: personal_key}, profile=name) # will be encrypted by setParam + + d.addCallback(initPersonalKey) d.addCallback(lambda dummy: self.setParam(C.PROFILE_PASS_PATH[1], password, C.PROFILE_PASS_PATH[0], profile_key=name)) return d