[16.0] web/session/authenticate endpoint returns an error instead of session_info
Impacted versions: odoo V16
Steps to reproduce: Send a POST request to web/session/authenticate endpoint with the correct user credentials as a body
{ "params": { "db":<DB>, "login": <LOGIN>, "password": <PASSWORD> } }
EDIT: To reproduce, there should be multiple databases under the same odoo instance and db_name = <DATABASE_NAME> not configured in the odoo config file (thanks to Mohamad Osama )
Current behavior: return an error message "'NoneType' object has no attribute 'user'"
Expected behavior: a JSON response with session info
{ "jsonrpc": "2.0", "id": null, "result": {...} }
Full log:
{ "jsonrpc": "2.0", "id": null, "error": { "code": 200, "message": "Odoo Server Error", "data": { "name": "builtins.AttributeError", "debug": "Traceback (most recent call last): File \"/odoo-16/odoo/http.py\", line 1963, in __call__ response = request._serve_nodb() File \"/odoo-16/odoo/http.py\", line 1516, in _serve_nodb response = self.dispatcher.dispatch(rule.endpoint, args) File \"/odoo-16/odoo/http.py\", line 1775, in dispatch result = endpoint(**self.request.params) File \"/odoo-16/odoo/http.py\", line 673, in route_wrapper result = endpoint(self, *args, **params_ok) File \"/odoo-16/addons/web/controllers/session.py\", line 52, in authenticate print('session_info', env['ir.http'].session_info()) File \"/odoo-16/addons/web_tour/models/ir_http.py\", line 12, in session_info result = super().session_info() File \"/odoo-16/addons/web/models/ir_http.py\", line 68, in session_info user = request.env.user AttributeError: 'NoneType' object has no attribute 'user' ", "message": "'NoneType' object has no attribute 'user'", "arguments": [ "'NoneType' object has no attribute 'user'" ], "context": {} } } }
Guys, please some one help us, I have the same problem the API for authenticate is not working
"'NoneType' object has no attribute 'user'"
i i have same problem. because env does not set to current request. When env setted in auth method at web module, cursor already closed error occured.
Fixed: https://github.com/odoo/odoo/commit/7b9bd9d37731fae724dc5d91da656dab70aa9ad4