catalyst / moodle-tool_mfa

A Multi-Factor Authentication Moodle plugin with flexible support for TOTP, Email, IP and more
https://moodle.org/plugins/tool_mfa
33 stars 38 forks source link

Fix for Double Submit Action in SMS Verification #460

Open Floris999 opened 3 weeks ago

Floris999 commented 3 weeks ago

Problem: The auto-submit for an SMS verification code can be triggered by two actions:

  1. The js_call auto-submit (triggered by an input of 6 numbers).
  2. The button in the verification step (a user click action).

Because of this, there are situations where the submit action is triggered twice, especially when the auto-submit takes a bit longer and the user is able to click on the button to submit the verification code. This causes problems because the $_SESSION is unset after submit. So when it runs for a second time, the $_SESSION factor phone variable is empty.

Solution: I have removed the auto-submit to prevent double invocation of setup_user_factor, which causes verification step failure due to session unset. So the submit action is always triggered by a click from the user.

Change in classes/local/form/verification_field.php:

`if ($PAGE->pagelayout === 'secure') { $this->appendjs = true; } else {

/**

*/ }`

justusdieckmann commented 3 weeks ago

I've opened a moodle issue in the tracker with a patch which keeps the auto-submission working: https://tracker.moodle.org/browse/MDL-82838