Exemplo n.º 1
0
    def on_get(self, req, res, store_id):
        session = req.context["session"]
        token = req.get_header("auth")
        auth_token = decrypt_token(token)
        if auth_token is not None:
            menu_db = (
                session.query(Store)
                .join(Menu)
                .filter(Store.id == int(store_id))
                .values(Menu.menuname, Menu.menu_set_option, Menu.menu_size_option, Store.name)
            )
            resullist = []
            for menuname, menu_set_option, menu_size_option, name in menu_db:
                resullist.append(
                    {
                        "menuanme": menuname,
                        "menu_set_option": menu_set_option,
                        "menu_size_option": menu_size_option,
                        "name": name,
                    }
                )
            res.status = falcon.HTTP_200
            res.body = self.to_json(resullist)

        else:
            res.status = falcon.HTTP_400
            res.body = self.to_json({"meta": {"code": 401, "message": "password not match"}})
Exemplo n.º 2
0
 def process_request(self, req, res, resource=None):
     LOG.debug("Authorization: %s", req.auth)
     if req.auth is not None:
         token = decrypt_token(req.auth)
         if token is None:
             raise UnauthorizedError("Invalid auth token: %s" % req.auth)
         else:
             req.context["auth_user"] = token.decode("utf-8")
     else:
         req.context["auth_user"] = None
Exemplo n.º 3
0
 def process_request(self, req, res):
     LOG.debug("Authorization: %s", req.auth)
     if req.auth is not None:
         token = decrypt_token(req.auth)
         if token is None:
             raise UnauthorizedError('Invalid auth token: %s' % req.auth)
         else:
             req.context['auth_user'] = token.decode('utf-8')
     else:
         req.context['auth_user'] = None
Exemplo n.º 4
0
 def process_request(self, req, res):
     LOG.debug("process_request() - Authorization: %s", req.auth)
     if req.auth is not None:
         token = decrypt_token(req.auth)
         # req.auth is like 'gAAAAABVwMgBhGf2xwfp4U3LuRUu7zToGxrrUZeWpRQxBPCPV-IZ2gZGtHBRQCqpP-16_ICFdgzE3YdKphQYcZ_PYYIdNGjhGFsxppag_B7yvmgQ6WceWF7lv3v8anr5o-m5-sOVtF1HdFm5zUxH1vW4vjgWsf4o6g=='
         # the decrypted token is like 'auth_type:id(email|facebook id):secret'
         # ex) 'email:[email protected]:CEfYjjxFWVh4aLUrAe9BMNaV'
         req.context['auth_user'] = token.decode('utf-8') if token else None
     else:
         req.context['auth_user'] = None