*

krallen

  • ***
  • 48 posts
I encountered a logic issue with the SMS Verification plugin related to how it checks
the verification status of a phone number.

The problem:
If a phone number was previously associated with another account (or even the same account)
and its status was marked as "CANCELED", the system may prevent the number from being
re-verified on a new attempt.

This happens because the getVerification function in ModelSMS.php does not sort records
by date. It simply fetches the first matching record from the database.
If an older "CANCELED" record is returned before the newer "VERIFIED" record,
the user remains "Not Verified" on the site even after successfully entering the SMS code.

The solution:
I fixed this by ordering the records by dt_date in descending order and limiting the
result to the most recent entry.

Updated code (oc-content/plugins/sms/model/ModelSMS.php):

Code: [Select]
public function getVerification($phone_number, $email = '') {
    $this->dao->select();
    $this->dao->from($this->getTable_sms_verification());
    $this->dao->where('s_phone_number', $phone_number);

    if (!empty($email)) {
        $this->dao->where('s_email', $email);
    }

    // Get the most recent verification record
    $this->dao->orderby('dt_date', 'DESC');
    $this->dao->limit(1);

    $result = $this->dao->get();

    if ($result && $result->numRows() > 0) {
        return $result->row();
    }

    return false;
}

With this change, the system correctly detects the most recent VERIFIED status,
regardless of any previous CANCELED records.

Thanks for the great plugin!

*

MB Themes

Thanks for feedback plugin was updated ;)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots