diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-03-09 06:11:55 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-03-09 06:11:55 +0700 |
| commit | 60c166f8b4f5f9cd8d4cdf6422f53d8b5d083648 (patch) | |
| tree | 439910148373c0b207838ec701a8bc13947b91d6 /indoteknik_api/controllers/api_v1/product.py | |
| parent | f790892bb6cf7bd7871e841af92ce3edfc76b8c2 (diff) | |
Optimize auth method
Diffstat (limited to 'indoteknik_api/controllers/api_v1/product.py')
| -rw-r--r-- | indoteknik_api/controllers/api_v1/product.py | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/indoteknik_api/controllers/api_v1/product.py b/indoteknik_api/controllers/api_v1/product.py index dc941f13..c9672223 100644 --- a/indoteknik_api/controllers/api_v1/product.py +++ b/indoteknik_api/controllers/api_v1/product.py @@ -12,10 +12,8 @@ class Product(controller.Controller): prefix = '/api/v1/' @http.route(prefix + 'new_product', auth='public', methods=['GET', 'OPTIONS']) + @controller.Controller.must_authorized() def get_new_product(self, **kw): - if not self.authenticate(): - return self.response(code=401, description='Unauthorized') - is_brand_only = int(kw.get('is_brand_only', 0)) base_url = request.env['ir.config_parameter'].get_param('web.base.url') @@ -85,10 +83,8 @@ class Product(controller.Controller): return self.response(data) @http.route(prefix + 'product', auth='public', methods=['GET', 'OPTIONS']) + @controller.Controller.must_authorized() def get_product(self, **kw): - if not self.authenticate(): - return self.response(code=401, description='Unauthorized') - name = kw.get('name') manufactures = kw.get('manufactures') categories = kw.get('categories') @@ -152,10 +148,8 @@ class Product(controller.Controller): return self.response(data) @http.route(prefix + 'product/solr', auth='public', methods=['GET']) + @controller.Controller.must_authorized() def get_product_solr(self, **kw): - if not self.authenticate(): - return self.response(code=401, description='Unauthorized') - name = kw.get('name') solr_flag = kw.get('flag') limit = int(kw.get('limit', 0)) @@ -183,10 +177,8 @@ class Product(controller.Controller): return self.response(data) @http.route(prefix + 'product/<id>', auth='public', methods=['GET']) + @controller.Controller.must_authorized() def get_product_by_id(self, **kw): - if not self.authenticate(): - return self.response(code=401, description='Unauthorized') - id = kw.get('id') if not id: return self.response(code=400, description='id is required') @@ -200,10 +192,8 @@ class Product(controller.Controller): return self.response(data) @http.route(prefix + 'product/<id>/similar', auth='public', methods=['GET', 'OPTIONS']) + @controller.Controller.must_authorized() def get_product_similar_by_id(self, **kw): - if not self.authenticate(): - return self.response(code=401, description='Unauthorized') - id = kw.get('id') if not id: return self.response(code=400, description='id is required') |
