Skip to content
Snippets Groups Projects
Commit 68cc7471 authored by Jinjiu Liu's avatar Jinjiu Liu
Browse files

[FIX] website_event: 404 when no track on register page


Reproduction:
1. Install eCommerce, Events, in the settings of Events, toggle
“Tickets” and “Online Ticketing”
2. Go to Website -> Go to Website -> Event, at the top bar, Customize ->
Track Visitor, turn it off
3. Click on the event “Open wood collection”, also turn off “Track
Visitor”
4. Click on the register button for this event, also turn off “Track
Visitor”
5. Copy the URL of the registration page, open it in an incognito tab.
Don’t go through from the beginning of the main website
6. Register a standard free ticket, enter the information, and click
confirm
7. The website throws a 404 not found error

Reason: when we turn off “Track Visitor” on the event registration page.
If we directly access the registration page, the created visitor’s
access token is not written in the cookies. Thus, when we call
_get_visitor_from_request after redirecting to
event_registration_success, the visitor isn’t retrieved and it causes a
404 not found error. A detailed case study is attached below.

Fix: before the redirection of successful registration, we check if the
logged visitor_uuid is the same as created visitor’s access token. If
not, e.g. the visitor_uuid is not logged, we log it in cookies.

opw-2828682

closes odoo/odoo#101635

Signed-off-by: default avatarThibault Delavallee (tde) <tde@openerp.com>
parent 08303459
Branches
Tags
No related merge requests found
......@@ -311,8 +311,17 @@ class WebsiteEventController(http.Controller):
def registration_confirm(self, event, **post):
registrations = self._process_attendees_form(event, post)
attendees_sudo = self._create_attendees_from_registration_post(event, registrations)
visitor_sudo = attendees_sudo.visitor_id
return request.redirect(('/event/%s/registration/success?' % event.id) + werkzeug.urls.url_encode({'registration_ids': ",".join([str(id) for id in attendees_sudo.ids])}))
redirect = request.redirect(('/event/%s/registration/success?' % event.id) + werkzeug.urls.url_encode({'registration_ids': ",".join([str(id) for id in attendees_sudo.ids])}))
# make sure the vistor's uuid is correctly logged in cookies when disabling "Track Visitor" on all the pages of the event
# we set visitor_uuid in the cookie to be sure "event_registration_success" can retrieve the visitor
if request.httprequest.cookies.get('visitor_uuid', '') != visitor_sudo.access_token:
expiration_date = datetime.now() + timedelta(days=365)
redirect.set_cookie('visitor_uuid', visitor_sudo.access_token, expires=expiration_date)
return redirect
@http.route(['/event/<model("event.event"):event>/registration/success'], type='http', auth="public", methods=['GET'], website=True, sitemap=False)
def event_registration_success(self, event, registration_ids):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment