Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force unconfirmed tickets to log in. #1421

Merged
merged 6 commits into from
Nov 15, 2024

Conversation

StevenDufresne
Copy link
Contributor

@StevenDufresne StevenDufresne commented Oct 30, 2024

Fixes #1420

Props mkrndmane, ryelle.

This PR forces login for editing tickets that are currently unconfirmed.

Changes

  • Adds user_must_confirm_ticket that checks if the ticket is unconfirmed. Reference
  • Passes along all tix_ parameters found in $_REQUEST to the final destination. Reference
    • I don't understand is why the original code checked for isset( $_REQUEST['tix_tickets_selected'] ) before passing along the parameters. I would assume we could pass them along in all cases.

How to test

  1. Purchase multiple tickets. (Stripe test cards, Stripe test keys)
    • Set a ticket to I don't know who will use this ticket yet
    • Set a ticket First Name/Last Name/Email.
  2. While viewing an Attendees post through the admin interface list:
    • Confirm the tix_username is set to [[ unconfirmed ]]
    • Copy the edit token link address.
  3. Visit that link in an incognito session.
  4. Confirm you are asked to login.
    • Note if you login with the same account you purchased your ticket with, this filter will stop you. You can comment out this one and the one below it to test if you don't have a second account to use
  5. Enter new details into the fields.
  6. Click the "Confirm Registration" button.
  7. View the attendee through the admin interface and confirm that their tix_username is set to the user that was used to log in.
  8. Copy the edit token link again.
  9. Log out.
  10. Paste that link in your browser.
  11. Update information and click "Save Attendee information"
  12. Notice that you are able to update the ticket information without logging in once the user is no longer [[ unconfirmed ]].

@StevenDufresne StevenDufresne marked this pull request as ready for review October 30, 2024 05:19
@pkevan
Copy link
Contributor

pkevan commented Oct 31, 2024

Unsure if this has been tested, but could this logic be extended to support users transferring their tickets to another username? Or is that supported elsewhere? I suppose on transfer of a ticket, it would just switch back to [[ unconfirmed ]]

@ryelle
Copy link
Contributor

ryelle commented Oct 31, 2024

I don't understand is why the original code checked for isset( $_REQUEST['tix_tickets_selected'] ) before passing along the parameters. I would assume we could pass them along in all cases.

Pretty sure that was just because I used $_REQUEST['tix_tickets_selected'] right below and wanted to make sure it wouldn't error.

I've tested out the edit ticket flow and a logged out user can correctly edit a ticket bought before the require-login, and not edit after 👍🏻

Unfortunately, in testing the regular ticket purchase flow I'm seeing this error:

Screenshot 2024-10-31 at 3 20 18 PM

I also realized the current redirect probably doesn't pass through the reservation info, but I was interrupted by ^ before I could properly test. A reservation is set up on a ticket (in the edit-ticket screen), and ends up being a link like somecamp.wordcamp.org/2024/tickets/?tix_reservation_id=speakers&tix_reservation_token=k3vlopd1G3vWewZA.

@ryelle
Copy link
Contributor

ryelle commented Oct 31, 2024

Oh, the error is because tix_tickets_selected should be an array of [ticket-id] => quantity, not an int.

@StevenDufresne
Copy link
Contributor Author

I think I've covered all the relevant parameters. Can I get another review?

* Get sanitized ticket parameters from request array.
*
* @param array $request_data Array of request data to sanitize.
* @return array Sanitized parameters.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess technically we could return an empty array too, if no parameters match the allowed list.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, $args will return empty if nothing matches. Do you think we should note that here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, @return array Empty array or sanitized parameters. or similar would work.

}
if ( ! is_user_logged_in() ) {

// Temporary: We don't want to block users from editing tickets unless they are unconfirmed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how long will this be temporary 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a script that will tell me when there are no more tickets purchased without accounts. Should be about February 2025.

Copy link
Contributor

@pkevan pkevan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

untested, but code looks ok.

@StevenDufresne StevenDufresne merged commit d83a6cd into production Nov 15, 2024
3 checks passed
@StevenDufresne StevenDufresne deleted the fix/bulk-edit-username-wiped branch November 15, 2024 00:11
@MakarandMane
Copy link

I will test it & get back here, found any issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Editing unconfirmed tickets clears the username.
4 participants