コード例 #1
0
 def get(self):
     digest_token = request.args.get("digest", '')
     logger.info('Get method is called to validate the e-mail')
     user = self.user_service.user_email_validate(digest_token)
     return results(status=user[0],
                    message=user[1],
                    data=user[2],
                    format_json=True)
コード例 #2
0
    def post(self):

        account_payload = request.get_json(force=True)
        account_payload['user_id'] = get_jwt_identity()
        account_payload['tenant_id'] = get_jwt_claims()['tenant_id']
        logger.info('Post method is called to autehnticate the use')
        user = self.user_service.user_account_create(account_payload)
        return results(status=user[0], message=user[1], data=user[2], format_json=True)
コード例 #3
0
 def post(self):
     account_payload = request.get_json(force=True)
     logger.info('Post method is called to autehnticate the use')
     user = self.user_service.authenticate_user(account_payload)
     return results(status=user[0],
                    message=user[1],
                    data=user[2],
                    format_json=True)
コード例 #4
0
 def get(self):
     user_id = get_jwt_identity()
     tenant_id = get_jwt_claims()['tenant_id']
     logger.info('Post method is called to validate the e-mail')
     user = self.user_service.validate_email_resend(user_id, tenant_id)
     return results(status=user[0],
                    message=user[1],
                    data=user[2],
                    format_json=True)
コード例 #5
0
 def get(self):
     '''
     This controller method is to retrieve the tenant info
     '''
     tenant_id = get_jwt_claims()['tenant_id']
     logger.info(
         'Get method is called to retrieve the tenant info for the id {0}'.format(tenant_id))
     tenant = self.user_service.tenant_get(tenant_id)
     return results(status=tenant[0], message=tenant[1], data=tenant[2], format_json=True)
コード例 #6
0
    def delete(self):
        '''
            This controller method is add delete the user

        '''
        user_id = get_jwt_identity()
        logger.info(
            'Delete method is called to delete the user with the id {0}'.format(user_id))
        self.user_service.delete(user_id)
        return results(status="success", message="User is Deleted!", data='', format_json=True)
コード例 #7
0
 def post(self):
     '''
     This controller method is to update the tenant info
     '''
     tenant_payload = request.get_json(force=True)
     tenant_id = get_jwt_claims()['tenant_id']
     logger.info('Post method is called update the tenant info {0} for the id {1}'.format(
         json.dumps(tenant_payload), tenant_id))
     tenant = self.user_service.tenant_update(tenant_id, tenant_payload)
     return results(status=tenant[0], message=tenant[1], data=tenant[2], format_json=True)
コード例 #8
0
    def post(self):
        '''
        This method is to update the password

        '''
        user_payload = request.get_json(force=True)
        logger.info(
            'Post method is called to update the password for the user')
        user = self.user_service.password_reset(user_payload)
        return results(status=user[0], message=user[1], data=user[2], format_json=True)
コード例 #9
0
    def get(self):
        '''
            This controller method is to retrieve teh use info

        '''
        user_id = get_jwt_identity()
        tenant_id = get_jwt_claims()['tenant_id']
        logger.info('User info will be retrieved for the user_id {0} and tenant_id {1}'.format(
            user_id, tenant_id))
        user = self.user_service.get(user_id, tenant_id)
        return results(status=user[0], message=user[1], data=user[2], format_json=True)
コード例 #10
0
ファイル: paymentcontroller.py プロジェクト: rnama22/amzorbit
 def get(self):
     '''
         This controller method is to retrieve teh card info
     '''
     user_id = get_jwt_identity()
     tenant_id = get_jwt_claims()['tenant_id']
     logger.info('Card info will be retrieved for the user_id {0} and tenant_id {1}'.format(
         user_id, tenant_id))
     # payment = self.payment_service.get(user_id,tenant_id)
     payment = self.payment_service.get(user_id)
     return results(status=payment[0], message=payment[1], data=payment[2], format_json=True)
コード例 #11
0
    def post(self):
        '''
            This controller method is to add the user

        '''

        user_payload = request.get_json(force=True)
        logger.info('Post method is called to register the user with the info {0}'.format(
            json.dumps(user_payload)))
        user = self.user_service.register(user_payload)
        return results(status=user[0], message=user[1], data=user[2], format_json=True)
コード例 #12
0
ファイル: jwtcontroller.py プロジェクト: rnama22/amzorbit
    def post(self):
        '''
        This method is to generate jwt token for the given payload
        '''
        jwt_payload = request.get_json(force=True)

        logger.info(
            'JWT token is being generated for the info {0}'.format(jwt_payload))

        jwt_token = self.user_service.authenticate_user(jwt_payload)
        return results(status="success", message="Feteched JWT Token", data=jwt_token, format_json=True)
コード例 #13
0
ファイル: paymentcontroller.py プロジェクト: rnama22/amzorbit
    def post(self):
        '''
            This controller method is to add the user

        '''
        payment_payload = request.get_json(force=True)
        payment_payload['payment_payload']['user_id'] = get_jwt_identity()
        # user_payload['tenant_id'] = get_jwt_claims()['tenant_id']
        logger.info('Post method is called to register the user with the info {0}'.format(
            json.dumps(payment_payload['payment_payload']['user_id'])))
        payment = self.payment_service.addPayment(payment_payload)
        return results(status=payment[0], message=payment[1], data=payment[2], format_json=True)
コード例 #14
0
ファイル: alertcontroller.py プロジェクト: rnama22/amzorbit
 def get(self):
     '''
         This controller method is to retrieve all the alerts for the given tenant
     '''
     tenant_id = get_jwt_claims()['tenant_id']
     logger.info(
         'Get method is called to retrieve all the alerts for the tenant {0}'
         .format(tenant_id))
     alert = self.alert_service.search({}, tenant_id)
     return results(status="success",
                    message="Fetched Alert",
                    data=alert,
                    format_json=True)
コード例 #15
0
    def get(self):
        '''
        This method is to validate JWT token

        '''
        # digest_token = reqparse.RequestParser()
        # digest_token.add_argument(
        #     'digest', type=str, help='digest cannot be converted')
        parser = reqparse.RequestParser()
        parser.add_argument('digest', type=str)
        logger.info(
            'Get method is called to validate the token ')
        user = self.user_service.validate_jwt_token(parser.parse_args())
        return results(status=user[0], message=user[1], data=user[2], format_json=True)
コード例 #16
0
 def post(self):
     '''
     This controller method is to update the alert for the given criteria and tenant
     '''
     alert_payload = request.get_json(force=True)
     user_id = get_jwt_identity()
     tenant_id = get_jwt_claims()['tenant_id']
     logger.debug(
         'Post method to update the alert with paylod {0} for the user {1} and tenant {2} is invoked'
         .format(json.dumps(alert_payload), user_id, tenant_id))
     self.alert_service.update(alert_payload, user_id, tenant_id)
     return results(status="success",
                    message="Alert Updated Successfully!",
                    data='',
                    format_json=True)
コード例 #17
0
    def post(self):
        '''
            This controller method is to retrieve the product given anysearch criteria

            As of now, it only retrieves the products for each tenant
        '''

        tenant_id = get_jwt_claims()['tenant_id']
        logger.debug(
            'Post method is invoked to retrieve the products for the tenant {0}'
            .format(tenant_id))
        product = self.product_service.search({}, tenant_id)
        return results(status="success",
                       message="Fetched Products",
                       data=product,
                       format_json=True)
コード例 #18
0
ファイル: productcontroller.py プロジェクト: rnama22/amzorbit
    def delete(self):
        '''
            This controller method is to delete a new product

            This needs jwt authentication and retrieves user id and tenant id from it

            It invokes delete method in the product service module
        '''
        product_id = request.args.get("product_id")
        tenant_id = get_jwt_claims()['tenant_id']

        logger.debug('Delete method is invoked to delete a product with product_id {0} and tenant_id {1}'.format(
            product_id, tenant_id))

        self.product_service.delete(int(product_id), int(tenant_id))
        return results(status="success", message="Deleted Product", data='', format_json=True)
コード例 #19
0
    def get(self):
        '''
            This controller method is to retrieve the product health status count

            This requires jwt authentication
        '''
        tenant_id = get_jwt_claims()['tenant_id']

        logger.debug(
            'Get method is invoked to get the products health status for the tenant {0}'
            .format(tenant_id))

        feed = self.product_service.status_count(tenant_id)
        return results(status="success",
                       message="Fetched the Status Count",
                       data=feed,
                       format_json=True)
コード例 #20
0
ファイル: productcontroller.py プロジェクト: rnama22/amzorbit
    def get(self):
        '''
        This controller method is to retrieve an existing product

        This needs jwt authentication and retrieves user id and tenant id from it

        It invokes get method in the product service module

        '''
        product_id = request.args.get("product_id")
        tenant_id = get_jwt_claims()['tenant_id']

        logger.debug('Get method is invoked to retrieve a product with product_id {0} and tenant_id {1}'.format(
            product_id, tenant_id))

        product = self.product_service.get(int(product_id), tenant_id)
        return results(status="success", message="Fetched Product", data=product, format_json=True)
コード例 #21
0
    def post(self):
        '''
            This controller method is to update the user info
        '''

        user_payload = request.get_json(force=True)
        user_payload['user_id'] = get_jwt_identity()
        user_payload['tenant_id'] = get_jwt_claims()['tenant_id']

        logger.info(
            'Post method is called to update the user info for the user_id {0} and tenant_id {1}'
            .format(user_payload['user_id'], user_payload['tenant_id']))

        user = self.user_service.update(user_payload)
        return results(status=user[0],
                       message=user[1],
                       data=user[2],
                       format_json=True)
コード例 #22
0
    def post(self):
        '''
        This controller method is invoke scrapping for a product product

        '''

        product_criteria = request.get_json(force=True)
        user_info = {'tenant_id': get_jwt_claims()['tenant_id']}

        logger.debug(
            'Post method is invoked to scrape the product {0} with the user info {1}'
            .format(json.dumps(product_criteria), json.dumps(user_info)))

        criteria = {**product_criteria, **user_info}
        self.product_service.scrape_limited(criteria)
        return results(status="success",
                       message="Scraping Initiated",
                       data='',
                       format_json=True)
コード例 #23
0
    def post(self):
        '''
            This controller is to update the product info for a given user

        '''

        product_payload = request.get_json(force=True)
        user_id = get_jwt_identity()
        tenant_id = get_jwt_claims()['tenant_id']

        logger.debug(
            'Post method is invoked to update the product{0} with user info{1}'
            .format(json.dumps(product_payload), json.dumps(tenant_id)))
        product = self.product_service.update(product_payload, user_id,
                                              tenant_id)
        return results(status="success",
                       message="Updated Product",
                       data=product,
                       format_json=True)
コード例 #24
0
ファイル: productcontroller.py プロジェクト: rnama22/amzorbit
    def post(self):
        '''
            This controller method is to add a new product

            This needs jwt authentication and retrieves user id and tenant id from it

            It invokes add method in the product service module

        '''
        products = request.get_json(force=True)
        user_info = {'user_id': get_jwt_identity(
        ), 'tenant_id': get_jwt_claims()['tenant_id']}

        logger.debug('Post method is invoked to add a new product {0} by user {1}'.format(
            json.dumps('products'), json.dumps(user_info)))

        products = {**products, **user_info}
        products_info = self.product_service.add(products)

        return results(status="success", message="Added Products", data=products_info, format_json=True)
コード例 #25
0
ファイル: jwtcontroller.py プロジェクト: rnama22/amzorbit
 def post(self):
     current_user_name = get_jwt_identity()
     refreshed_jwt_token = self.user_service.jwt_token_refresh(
         current_user_name)
     return results(status="success", message="Fetched Refreshed JWT Token", data=refreshed_jwt_token, format_json=True)