Exemple #1
0
    def __init__(self, created_by='web', valid_until=None):
        """ Create a new activation, valid_until is a datetime, 
        defaults to 3 days from current day
        """
        self.code =  generate_random_string(12)
        self.created_by = created_by

        if valid_until:
            self.valid_until = valid_until
        else:
             self.valid_until = datetime.utcnow() + timedelta(days=3)
Exemple #2
0
 def generate_random_password(cls, chars=12):
     """ generates random string of fixed length"""
     return generate_random_string(chars)
Exemple #3
0
    def hash_password(self, password):
        if not self.salt:
            self.salt = generate_random_string(24)

        return unicode(crypt.encode(password + self.salt))