checked the db_name
This commit is contained in:
parent
6082c2af96
commit
0f5731fcc5
|
|
@ -38,9 +38,11 @@ class AuthenticationController(http.Controller):
|
||||||
return http_helper.response(code=400, message=_('FCM Token is missing'), success=False)
|
return http_helper.response(code=400, message=_('FCM Token is missing'), success=False)
|
||||||
|
|
||||||
# Set the database for the request environment
|
# Set the database for the request environment
|
||||||
if db:
|
# if db:
|
||||||
ensure_db()
|
# ensure_db()
|
||||||
|
if request.session.db and request.session.db != db:
|
||||||
|
request.session.logout()
|
||||||
|
request.session.db = db
|
||||||
# Authenticate user
|
# Authenticate user
|
||||||
uid = http_helper.is_authentic(login, password)
|
uid = http_helper.is_authentic(login, password)
|
||||||
if not uid:
|
if not uid:
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,25 @@
|
||||||
import odoo
|
import odoo
|
||||||
from odoo import http
|
from odoo import http
|
||||||
from odoo.http import request
|
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):
|
class WebController(http.Controller):
|
||||||
@http.route('/web/session/authenticate', type='json', auth="none")
|
@http.route('/web/session/authenticate', type='json', auth="none")
|
||||||
def authenticate(self, login, password, base_location=None):
|
def authenticate(self, login, password, base_location=None, db=None):
|
||||||
db = odoo.tools.config.get('db_name')
|
if db:
|
||||||
if not db:
|
if db not in http.db_filter([db]):
|
||||||
response_data = {
|
return {"error": "Database not allowed", "status": 403}
|
||||||
"error": "Database name should be specified in Conf File",
|
if request.session.db and request.session.db != db:
|
||||||
"status": 400
|
request.session.logout()
|
||||||
}
|
request.session.db = db
|
||||||
return response_data
|
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)
|
request.session.authenticate(db, login, password)
|
||||||
return request.env['ir.http'].session_info()
|
return request.env['ir.http'].session_info()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue