def get_password_reset_key(self, secretanswer): """Generate and return a new key to reset the password Requires the correct secretanswer, if there is one """ if (self.secretanswer and secretanswer.replaceany(name, kiwioptions.KIWI_NAME_LOOKUP_IGNORE_CHARS, "").lower() != self.secretanswer.replaceany(name, kiwioptions.KIWI_NAME_LOOKUP_IGNORE_CHARS, "").lower()): return None self.resetkey = codes.make_random_code(10) + "." + self.name # Add in name so no chance of duplication db.put() return self.resetkey
def validate(self, value): if value is None: return codes.make_random_code(6) return value