[UPD] odex_mobile

This commit is contained in:
Samir Ladoui 2025-05-28 14:47:43 +01:00
parent 4e6853fefe
commit 043c9c209e
1 changed files with 11 additions and 1 deletions

View File

@ -13,6 +13,7 @@ from ...http_helper import http_helper
from ...data_util import data_util
import json
import logging
import time
from odoo.tools.translate import _
_logger = logging.getLogger(__name__)
@ -24,12 +25,17 @@ class AuthenticationController(http.Controller):
@http.route('/rest_api/validate',type='http', auth='none', csrf=False, cors='*',methods=['POST'])
def validate_token(self, **kw):
start_time_pc = time.perf_counter()
http_method, body, headers, token = http_helper.parse_request()
result = validator.validate_token(token)
_logger.info("DEBUG VALIDATION: %s", result)
if result['code'] == 497 or result['code'] == 498:
return http_helper.errcode(code=result['code'], message=result['message'])
end_time_pc = time.perf_counter()
execution_time_pc = end_time_pc - start_time_pc
_logger.info("TIME VALIDATION API: %s seconds", execution_time_pc)
return http_helper.response(message="uploaded success",data=result['data'])
@http.route('/rest_api/refresh',type='http', auth='none', csrf=False, cors='*',methods=['POST'])
@ -210,6 +216,7 @@ class AuthenticationController(http.Controller):
@http.route('/rest_api/login', type='http', auth='none', csrf=False, cors='*', methods=['POST'])
def login_phone(self, **kw):
start_time_pc = time.perf_counter()
login=kw.get('login')
password=kw.get('password')
if not login :
@ -244,5 +251,8 @@ class AuthenticationController(http.Controller):
dic['token'] = token
dic['is_approve'] = 'group_division_manager' in dic.get('groups',[])
http_helper.cleanup();
http_helper.cleanup()
end_time_pc = time.perf_counter()
execution_time_pc = end_time_pc - start_time_pc
_logger.info("TIME LOGIN API: %s seconds", execution_time_pc)
return http_helper.response(data=dic, message=_("User log in successfully"))