Merge pull request #4032 from expsa/fix_multi_db

checked the db_name
This commit is contained in:
mohammed-alkhazrji 2025-07-28 15:06:14 +03:00 committed by GitHub
commit d882534d24
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 12 deletions

View File

@ -38,9 +38,11 @@ class AuthenticationController(http.Controller):
return http_helper.response(code=400, message=_('FCM Token is missing'), success=False)
# Set the database for the request environment
if db:
ensure_db()
# if db:
# ensure_db()
if request.session.db and request.session.db != db:
request.session.logout()
request.session.db = db
# Authenticate user
uid = http_helper.is_authentic(login, password)
if not uid:

View File

@ -1,18 +1,25 @@
import odoo
from odoo import http
from odoo.http import request
from odoo import tools
from odoo.addons.web.controllers.main import ensure_db
from odoo.http import request, db_filter
class WebController(http.Controller):
@http.route('/web/session/authenticate', type='json', auth="none")
def authenticate(self, login, password, base_location=None):
db = odoo.tools.config.get('db_name')
if not db:
response_data = {
"error": "Database name should be specified in Conf File",
"status": 400
}
return response_data
def authenticate(self, login, password, base_location=None, db=None):
if db:
if db not in http.db_filter([db]):
return {"error": "Database not allowed", "status": 403}
if request.session.db and request.session.db != db:
request.session.logout()
request.session.db = db
else:
db = tools.config.get('db_name')
if not db:
return {"error": "Database name should be specified in Conf File or passed in request", "status": 400}
ensure_db()
request.session.authenticate(db, login, password)
return request.env['ir.http'].session_info()