예제 #1
0
파일: forms.py 프로젝트: ephilippot/kansha
    def create_token(self):
        """Create a time-stamped token"""
        token = unicode(hashlib.sha512(str(time.time()) + self.username).hexdigest())

        DataToken.delete_token_by_username(self.username, self.action)
        # create new one
        token_instance = DataToken(
            token=token, username=self.username, action=self.action, date=datetime.now() + self.expiration_delay
        )
        return token_instance
예제 #2
0
파일: forms.py 프로젝트: ephilippot/kansha
 def reset_token(self, token):
     DataToken.get(token).delete()
예제 #3
0
파일: forms.py 프로젝트: ephilippot/kansha
 def check_token(self, token):
     """Check that the token is valid"""
     t = DataToken.get(token)
     return t and datetime.now() <= t.date