[FIX] web: expect explicit sign up parameters

Using an explicit list of sign up parameters will avoid
polluting the context with unrelated values, and make
debugging easier.
This commit is contained in:
Olivier Dony
2021-10-02 15:04:53 +02:00
parent 8ae1a43663
commit 3cbc0915bb
2 changed files with 7 additions and 3 deletions
+2 -2
View File
@@ -5,7 +5,7 @@ import werkzeug
from odoo import http, _
from odoo.addons.auth_signup.models.res_users import SignupError
from odoo.addons.web.controllers.main import ensure_db, Home
from odoo.addons.web.controllers.main import ensure_db, Home, SIGN_UP_REQUEST_PARAMS
from odoo.addons.base_setup.controllers.main import BaseSetup
from odoo.exceptions import UserError
from odoo.http import request
@@ -101,7 +101,7 @@ class AuthSignupHome(Home):
def get_auth_signup_qcontext(self):
""" Shared helper returning the rendering context for signup and reset password """
qcontext = request.params.copy()
qcontext = {k: v for (k, v) in request.params.items() if k in SIGN_UP_REQUEST_PARAMS}
qcontext.update(self.get_auth_signup_config())
if not qcontext.get('token') and request.session.get('auth_signup_token'):
qcontext['token'] = request.session.get('auth_signup_token')
+5 -1
View File
@@ -561,6 +561,10 @@ class HomeStaticTemplateHelpers(object):
def get_qweb_templates(cls, addons=None, db=None, debug=False, bundle=None):
return cls(addons, db, debug=debug)._get_qweb_templates(bundle)[0]
# Shared parameters for all login/signup flows
SIGN_UP_REQUEST_PARAMS = {'db', 'login', 'debug', 'token', 'message', 'error', 'scope', 'mode',
'redirect', 'redirect_hostname', 'email', 'name', 'partner_id',
'password', 'confirm_password', 'city', 'country_id', 'lang'}
class GroupsTreeNode:
"""
@@ -848,7 +852,7 @@ class Home(http.Controller):
if not request.uid:
request.uid = odoo.SUPERUSER_ID
values = request.params.copy()
values = {k: v for k, v in request.params.items() if k in SIGN_UP_REQUEST_PARAMS}
try:
values['databases'] = http.db_list()
except odoo.exceptions.AccessDenied: