[FIX] google_recaptcha: Add key in session_info

Before this commit, if there was a Google ReCaptcha public key
registered on the database, it was given to the backend along with
the assets in the `session_info` global key.

Since this key is meant to be used on the frontend to generate recaptcha
tokens, it should be available there as well.

Now, it is also given to the frontend version of the `session_info` key.

closes odoo/odoo#76600

Task: 2639095
X-original-commit: 27136cd09abfb4e012b0df2d53877534cbcdad28
Signed-off-by: Julien Mougenot (jum) <jum@odoo.com>
This commit is contained in:
Julien Mougenot
2021-09-15 17:50:41 +00:00
parent 499b1621ba
commit 5cffff6e60
+10
View File
@@ -15,6 +15,16 @@ class Http(models.AbstractModel):
def session_info(self):
session_info = super().session_info()
return self._add_public_key_to_session_info(session_info)
@api.model
def get_frontend_session_info(self):
frontend_session_info = super().get_frontend_session_info()
return self._add_public_key_to_session_info(frontend_session_info)
@api.model
def _add_public_key_to_session_info(self, session_info):
"""Add the ReCaptcha public key to the given session_info object"""
public_key = self.env['ir.config_parameter'].sudo().get_param('recaptcha_public_key')
if public_key:
session_info['recaptcha_public_key'] = public_key