Example #1
0
 def reset_seed(self, seed=None):
     """
     Resets seed to `seed` or to a new random seed, and takes care of
     everything that needs to be done after that (e.g. reseting HOTP
     counter). Doesn't save the model.
     """
     if seed is None:
         seed = random_seed(30)
     self.encrypted_seed = encrypt_value(seed)
     self.counter = 0
Example #2
0
    def save(self):
        if not self.user:
            return None

        try:
            token = UserAuthToken.objects.get(user=self.user)
        except UserAuthToken.DoesNotExist:
            token = UserAuthToken(user=self.user)

        token.encrypted_seed = encrypt_value(random_seed(30))
        token.save()
        return token