From fff721dd185f5b97f7ae7a6e64189e55887ff590 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 05 Jul 2026 18:36:57 +0000
Subject: [PATCH] =Cleaning up the Square integration (still a bit more to do yet). Also majorly overhauled /rest/ files to ignore a rest request 'user' paramater, and rely on get_current_user_id() instead.
---
inc/managers/MagicLinkManager.php | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/inc/managers/MagicLinkManager.php b/inc/managers/MagicLinkManager.php
index 8d642f5..30c11f4 100644
--- a/inc/managers/MagicLinkManager.php
+++ b/inc/managers/MagicLinkManager.php
@@ -85,6 +85,7 @@
protected function generateToken(string $email, string $type, array $data = []): string
{
$token = wp_generate_password(32, false);
+ error_log('Generated Token: '.$token);
$token_data = array_merge([
'email' => $email,
@@ -96,9 +97,12 @@
if ($type === self::TYPE_REFERRAL) {
$this->referral_cache->set($token, $token_data);
} else {
+ error_log('Setting to $this->cache');
$this->cache->set($token, $token_data);
}
+ error_log('Generated token: '.print_r($token_data, true));
+
return $token;
}
@@ -107,8 +111,10 @@
*/
public function verifyToken(string $token, string $email): array|WP_Error
{
+ error_log('Verifying token: '.$token);
// Try regular cache first, then referral cache
$token_data = $this->cache->get($token);
+ error_log('Got token data from cache: '.print_r($token_data, true));
if (!$token_data) {
$token_data = $this->referral_cache->get($token);
@@ -302,7 +308,6 @@
if (!isset($_GET['magic_token']) || !isset($_GET['action']) || !isset($_GET['email'])) {
return;
}
-
$action = sanitize_text_field($_GET['action']);
$token = sanitize_text_field($_GET['magic_token']);
$email = sanitize_email(rawurldecode($_GET['email']));
@@ -315,7 +320,6 @@
if (is_wp_error($token_data)) {
$this->cleanURL();
- return;
}
switch ($action) {
@@ -358,6 +362,7 @@
$user = get_user_by('ID', $token_data['user_id']);
if (!$user) {
+ error_log('No user found: '.print_r($user, true));
wp_die('Invalid user');
}
--
Gitblit v1.10.0