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/rest/routes/ApprovalRoutes.php | 10 ++--------
1 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/inc/rest/routes/ApprovalRoutes.php b/inc/rest/routes/ApprovalRoutes.php
index b35e485..b4129a7 100644
--- a/inc/rest/routes/ApprovalRoutes.php
+++ b/inc/rest/routes/ApprovalRoutes.php
@@ -55,7 +55,6 @@
Route::for('approvals')
->get([$this, 'getApprovals'])
->args([
- 'user' => 'integer|required',
'type' => 'string',
'status' => 'string|enum:pending,approved,rejected,expired',
])
@@ -63,7 +62,6 @@
->rateLimit(30)
->post([$this, 'handleAction'])
->args([
- 'user' => 'integer|required',
'request_id' => 'integer|required',
'action' => 'string|required|enum:approve,reject',
'type' => 'string|required',
@@ -84,7 +82,7 @@
{
$data = $request->get_params();
$request_id = absint($data['request_id']);
- $user_id = absint($data['user']);
+ $user_id = get_current_user_id();
$action = sanitize_text_field($data['action']);
$type = sanitize_text_field($data['type']);
$notes = sanitize_text_field($data['notes'] ?? '');
@@ -208,14 +206,10 @@
public function getApprovals(WP_REST_Request $request): WP_REST_Response
{
- $user_id = absint($request->get_param('user'));
+ $user_id = get_current_user_id();
$type = sanitize_text_field($request->get_param('type') ?? 'all');
$status = sanitize_text_field($request->get_param('status') ?? 'pending');
- if (!$this->checkUser($user_id)) {
- return $this->unauthorized();
- }
-
$cacheKey = compact('user_id', 'type', 'status');
$result = $this->cache->remember($cacheKey, function() use ($type, $status) {
--
Gitblit v1.10.0