[IMP] pms-api-rest: adapt jwt auth to oca/rest-framework's lasts udpates

This commit is contained in:
miguelpadin
2021-12-26 12:06:28 +01:00
committed by Darío Lodeiros
parent 72d7600755
commit 7f6faae55d
13 changed files with 17 additions and 527 deletions

View File

@@ -1,22 +1,7 @@
from odoo.addons.base_rest.controllers import main
from ..lib_jwt.jwt_http import jwt_http
from ..lib_jwt.validator import validator
class BaseRestDemoPublicApiController(main.RestController):
_root_path = "/api/"
_collection_name = "pms.reservation.service"
_default_auth = "public"
# RestController OVERRIDE method
def _process_method(self, service_name, method_name, *args, params=None):
http_method, body, headers, token = jwt_http.parse_request()
result = validator.verify_token(token)
if not result["status"]:
return jwt_http.errcode(code=result["code"], message=result["message"])
else:
return super(BaseRestDemoPublicApiController, self)._process_method(
service_name, method_name, *args, params=params
)
_default_auth = "jwt_api_pms"