From 4089ba01e0881c89a72332e13bc3a80b6bddec2a Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Mon, 29 Jun 2026 22:15:55 +0000
Subject: [PATCH] =DashboardManager overhaul. A bit easier to modify the output of pages. Still have to get the account pages to work as expected, as well as verify the integrations and others are working - but registrar/content pages work as expected. Also fixed up the table generation in CRUD.js and CRUDSkeleton.php
---
inc/rest/routes/LoginRoutes.php | 39 ++++++++++++++++++++++-----------------
1 files changed, 22 insertions(+), 17 deletions(-)
diff --git a/inc/rest/routes/LoginRoutes.php b/inc/rest/routes/LoginRoutes.php
index 2e863ee..5d8218b 100644
--- a/inc/rest/routes/LoginRoutes.php
+++ b/inc/rest/routes/LoginRoutes.php
@@ -31,8 +31,8 @@
$this->cacheTtl = WEEK_IN_SECONDS;
parent::__construct();
+ $this->hasMagicLink = Site::has('magic_link');
- $this->hasMagicLink = Site::has('magicLink');
}
public function registerRoutes(): void
@@ -95,7 +95,8 @@
->register();
// Magic link endpoint
- if ($this->hasMagicLink) {
+
+ if (Site::has('magic_link')) {
Route::for('auth/magic')
->post([$this, 'handleMagicLink'])
->args([
@@ -136,18 +137,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
@@ -416,7 +422,8 @@
*/
public function handleMagicLink(WP_REST_Request $request): WP_REST_Response
{
- if (!$this->hasMagicLink) {
+
+ if (!Site::has('magic_link')) {
return $this->error(
'Magic link authentication is not enabled.',
'feature_disabled',
@@ -720,22 +727,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 +752,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