Opened 10 years ago

Closed 7 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


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/,566#L542.

The following patch at least works around the issue:

  • accountmanagerplugin/trunk/acct_mgr/

    diff --git a/accountmanagerplugin/trunk/acct_mgr/ b/accountmanagerplu
    index 5008350..4c2eec2 100644
    a b class EmailVerificationModule(CommonTemplateProvider): 
    546546            # Permissions for anonymous users remain unchanged.
    547547            return handler
    548548        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':
    550551            try:
    551552                AccountManager(self.env).validate_account(req)
    552553                # Check passed without error: New email address seems good.

Attachments (0)

Change History (7)

comment:1 Changed 10 years ago by Steffen Hoffmann

Too bad there is no dedicated URL for such preferences, so I see no chance to avoid such a rather ugly condition refinement too.

comment:2 Changed 10 years ago by Ryan J Ollos

I'll keep that in mind while working trac:#11612. We might be able to improve things on the trunk.

comment:3 in reply to:  2 Changed 10 years ago by Steffen Hoffmann

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:4 Changed 10 years ago by Steffen Hoffmann

In 14272:

AccountManagerPlugin: Ignore AJAX POST requests from Trac core, refs #12050.

User preferences for activating alternative ticket change history
presentations have been added in Trac 1.0.

Filtering requests to '/prefs' more strictly in EmailVerificationModule
works around the reported failure of saving these new preferences, if that
account manager module is enabled.

In the long run it would be good to keep request to Trac URLs like '/admin' or
'/prefs' more backwards-compatible.

comment:5 Changed 10 years ago by Steffen Hoffmann

Status: newaccepted

comment:6 Changed 10 years ago by Steffen Hoffmann

Keywords: preferences added
Trac Release: 1.0

comment:7 Changed 7 years ago by Ryan J Ollos

Resolution: fixed
Status: acceptedclosed

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Steffen Hoffmann.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.