Files
encoach_backend_new_v2/odoo/addons/account_peppol/controllers/authentication.py
Yamen Ahmad 3e83d8d7d5 feat: add complete EnCoach backend — Odoo 19 + all addons
Includes:
- Odoo 19 framework (odoo/)
- 27 custom EnCoach addons (new_project/custom_addons/)
  - encoach_core, encoach_api, encoach_lms_api, encoach_adaptive_api
  - encoach_exam, encoach_taxonomy, encoach_adaptive, encoach_assignment
  - encoach_ai, encoach_ai_grading, encoach_ai_generation, encoach_ai_media
  - encoach_courseware, encoach_communication, encoach_subscription
  - encoach_notification, encoach_approval, encoach_branding
  - encoach_classroom, encoach_registration, encoach_stats
  - encoach_faq, encoach_ticket, encoach_training, encoach_resources
  - encoach_adaptive_ai, encoach_sis
- 21 OpenEduCat Enterprise modules (new_project/enterprise-19/)
- 14 OpenEduCat Community modules (new_project/openeducat_erp-19.0/)
- Configuration: odoo.conf, requirements.txt, scripts
- 200+ REST API endpoints with JWT authentication
- SRS and test documentation

Made-with: Cursor
2026-04-01 17:10:04 +04:00

42 lines
2.1 KiB
Python

import logging
from odoo import http
from odoo.exceptions import UserError
from odoo.http import request
_logger = logging.getLogger(__name__)
class PeppolAuthentication(http.Controller):
@http.route('/peppol/authentication/callback', type='http', methods=['GET'], auth='user')
def peppol_authentication_callback(self, auth_type, connect_token, auth_token=None):
""" Route called by the Proxy Server after authentication."""
def redirect(success=True, partner=None, error_message=None):
if partner:
# Notify the root/initial window of the authentication result. See JS service "peppol_auth_service".
partner._bus_send("peppol_auth_channel", {'auth_result': 'success' if success else 'failure', 'error_message': error_message})
# Action to close the window opened for authentication
return request.redirect_query('/odoo/peppol-auth-callback-action', query={'success': success})
connect_data = request.env['peppol.registration']._decode_connect_token(connect_token)
if not connect_data:
_logger.warning("Invalid request token auth_type=%s connect_token=%s auth_token=%s", auth_type, connect_token, auth_token)
return redirect(success=False)
partner = connect_data['partner']
if not auth_token:
_logger.warning("Invalid auth token auth_type=%s connect_token=%s auth_token=%s", auth_type, connect_token, auth_token)
return redirect(success=False, partner=partner)
peppol_identifier = connect_data['peppol_identifier']
db_uuid = request.env['ir.config_parameter'].get_param('database.uuid')
company = connect_data['company']
try:
request.env['peppol.registration'].sudo()._create_connection(peppol_identifier, db_uuid, company, auth_token=auth_token)
except UserError as e:
_logger.warning("Could not create proxy user auth_type=%s connect_token=%s auth_token=%s", auth_type, connect_token, auth_token)
return redirect(success=False, partner=partner, error_message=str(e))
return redirect(success=True, partner=partner)