Opened 10 years ago
Closed 8 years ago
#12050 closed defect (fixed)
Ticket preferences are not saved
Reported by: | Ryan J Ollos | Owned by: | Steffen Hoffmann |
---|---|---|---|
Priority: | normal | Component: | AccountManagerPlugin |
Severity: | normal | Keywords: | preferences |
Cc: | Trac Release: | 1.0 |
Description
Reported in trac:#11612 and trac:#11808, the ticket preferences comment sort order and comments only are not saved from an authenticated session. This is due to Registration.pre_process_request()
intercepting the AJAX post and redirecting.
Here are the comments that were originally posted to trac:#11612:
I can reproduce the issue in this ticket as well as trac:#11808 when AccountManagerPlugin is installed. Setting a breakpoint at the location the AJAX callback is processed, I see thatreq.method == 'GET'
when AccountManagerPlugin is enabled, which is the direct cause for the preference not being saved.
As to the reason why this is a GET
request rather than a POST
, the only guess I have at the moment is that another handler in account manager matches the request and redirects, converting the jQuery AJAX POST request to a GET. I'll debug further when I have more time tomorrow.
The problem is in EmailVerificationModule.pre_process_request()
. When the user is authenticated the account validation is executed in response to an AJAX POST, which raises a RegistrationError
exception with message You must specify a valid email address (which Jun noted as seeing in trac:comment:7:ticket:11808): accountmanagerplugin/trunk/acct_mgr/register.py@14078:551,566#L542.
The following patch at least works around the issue:
-
accountmanagerplugin/trunk/acct_mgr/register.py
diff --git a/accountmanagerplugin/trunk/acct_mgr/register.py b/accountmanagerplu index 5008350..4c2eec2 100644
a b class EmailVerificationModule(CommonTemplateProvider): 546 546 # Permissions for anonymous users remain unchanged. 547 547 return handler 548 548 elif req.path_info == '/prefs' and req.method == 'POST' and \ 549 not 'restore' in req.args: 549 not 'restore' in req.args and \ 550 not req.get_header('X-Requested-With') == 'XMLHttpRequest': 550 551 try: 551 552 AccountManager(self.env).validate_account(req) 552 553 # Check passed without error: New email address seems good.
Attachments (0)
Change History (7)
comment:1 Changed 10 years ago by
comment:2 follow-up: 3 Changed 10 years ago by
I'll keep that in mind while working trac:#11612. We might be able to improve things on the trunk.
comment:3 Changed 10 years ago by
I'll do the fix here.
Replying to rjollos:
I'll keep that in mind while working trac:#11612. We might be able to improve things on the trunk.
Yes. Neither these settings nor other new general (new) ones should be sent to /pref
, to avoid such side-effects. I remember having seen a dedicated path for AJAX requests in DiscussionPlugin; could be worth adopting that pattern for clarity.
comment:5 Changed 10 years ago by
Status: | new → accepted |
---|
comment:6 Changed 10 years ago by
Keywords: | preferences added |
---|---|
Trac Release: | → 1.0 |
comment:7 Changed 8 years ago by
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
Too bad there is no dedicated URL for such preferences, so I see no chance to avoid such a rather ugly condition refinement too.