From ba1e1ccf869b818f7a7a897264dfea05563a7796 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 07 Jun 2026 20:10:20 +0000
Subject: [PATCH] =Major overhaul of Integrations. Playing around with adding fields to post types through Registrar from an integrations' class file.
---
inc/rest/routes/LoginRoutes.php | 31 +++++++++++++++++--------------
1 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/inc/rest/routes/LoginRoutes.php b/inc/rest/routes/LoginRoutes.php
index 2e863ee..b4563aa 100644
--- a/inc/rest/routes/LoginRoutes.php
+++ b/inc/rest/routes/LoginRoutes.php
@@ -136,18 +136,23 @@
*/
public function handleLogin(WP_REST_Request $request): WP_REST_Response
{
+ error_log('Handling login...');
$email = sanitize_email($request->get_param('user_email'));
$password = $request->get_param('user_password');
$remember = (bool) $request->get_param('remember_me');
$redirect_to = $request->get_param('redirect_to');
// Verify Turnstile
+
if (!$this->verifyTurnstile($request->get_param('cf-turnstile-response') ?? '')) {
+ error_log('[handleLogin]Turnstile failed');
return $this->error(
'Security verification failed. Please try again.',
'turnstile_failed',
403
);
+ } else {
+ error_log('[handleLogin]Turnstile succeeded');
}
// Attempt authentication
@@ -720,22 +725,20 @@
protected function buildAuth(?int $user = null): array
{
$userId = $user ?? (is_user_logged_in() ? get_current_user_id() : 0);
- $cacheKey = $userId ?: 'guest';
- return Cache::for('auth', 300)->remember($cacheKey, function() use ($userId) {
- if ($userId) {
- return [
- 'authenticated' => true,
- 'user' => $userId,
- 'nonces' => $this->getUserNonces($userId),
- ];
- }
+ if ($userId) {
return [
- 'authenticated' => false,
- 'user' => false,
- 'nonces' => ['wp_rest' => wp_create_nonce('wp_rest')],
+ 'authenticated' => true,
+ 'user' => $userId,
+ 'nonces' => $this->getUserNonces($userId),
];
- });
+ }
+
+ return [
+ 'authenticated' => false,
+ 'user' => false,
+ 'nonces' => ['wp_rest' => wp_create_nonce('wp_rest')],
+ ];
}
protected function getUserNonces(int $userID):array {
$nonces = [
@@ -747,7 +750,7 @@
if (Site::has('favourites')) {
$nonces['favourites'] = wp_create_nonce('favourites-'.$userID);
}
- if (!empty(Registrar::getFeatured('karma'))) {
+ if (!empty(Registrar::withFeature('karma'))) {
$nonces['votes'] = wp_create_nonce('votes-'.$userID);
}
if (Site::has('notifications')) {
--
Gitblit v1.10.0