Exemple #1
0
 def find_by(cls, **kw):
     from topdish.lib import security as securitylib
     if 'email' in kw:
         email = kw['email']
         del kw['email']
         kw['email_hash'] = securitylib.hash(email)
     return super(User, cls).find_by(**kw)
Exemple #2
0
    def generate_email_access_token(self, commit=True):
        from topdish.lib import security as securitylib

        expiry = (int(time.time()) / 86400 + 7) * 86400
        token_text = '%s%s%s' % (expiry, self.email_hash, self.password_hash)
        self.email_access_token = securitylib.hash(token_text, salt=self.salt)
        self.email_access_token_expiry = expiry

        if commit:
            self.get_session().commit()
Exemple #3
0
 def check_password(self, cleartext):
     from topdish.lib import security as securitylib
     return securitylib.hash(cleartext, salt=self.salt) == self.password_hash
Exemple #4
0
 def _set_password(self, password):
     """
     Set the user's password_hash to the hash of the new plaintext
     """
     from topdish.lib import security as securitylib
     self.password_hash = securitylib.hash(password, salt=self.salt)
Exemple #5
0
 def before_update(self):
     from topdish.lib import security as securitylib
     super(User, self).before_update()
     if self.email:
         self.email_hash = securitylib.hash(self.email)