Esempio n. 1
0
    def __before__(self):
        # set user info
        c.is_authorized = False
        c.user_name = "Anonymous"

        token = get_token()
        if token:
            c.user_name = parse_token(token)[0]
            c.is_authorized = True
Esempio n. 2
0
 def check_auth(self):
     token = get_token()
     if not token:
         log.error("%s token received" % token)
         abort(401)
     id, timestamp = parse_token(token)
     delta = datetime.datetime.now() - datetime.datetime.strptime(timestamp, "%Y-%m-%dT%H:%M:%S")
     if delta.seconds > 3600:
         log.info("timestamp is too old...")
         abort(401)
         # set user_name to real name
     c.player = meta.Session.query(Player).filter(Player.id == id).one()
     log.debug("user %s passed challange of times." % c.player)
     return id, timestamp