From 772462eeca3002a1d52508aeba485aab2b4742ad Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 03 Mar 2026 19:06:19 +0000
Subject: [PATCH] =MAJOR OVERHAUL. Likely should have made a new branch ages ago. Key changes: Registrar.php is the base for custom post types, taxonomies, and user roles. Replaces JVB_CONTENT, JVB_TAXONOMY, and JVB_USER constants, eliminates most of Features.php (except for JVB_SITE, JVB_MEMBERSHIP), and has built in sanitizing and validation via sub-classes. Also started a major overhaul of the Schema output. Created a shit ton of property traits and classes to help sanitize and ensure proper data for different schema types. Still a bunch to do, but better to be starting committing changes here on this other branch.
---
inc/rest/routes/LoginRoutes.php | 50 +++++++++++++++++---------------------------------
1 files changed, 17 insertions(+), 33 deletions(-)
diff --git a/inc/rest/routes/LoginRoutes.php b/inc/rest/routes/LoginRoutes.php
index 2898b23..10e448f 100644
--- a/inc/rest/routes/LoginRoutes.php
+++ b/inc/rest/routes/LoginRoutes.php
@@ -1,6 +1,7 @@
<?php
namespace JVBase\rest\routes;
+use JVBase\registrar\Registrar;
use JVBase\rest\Rest;
use JVBase\rest\Route;
use JVBase\utility\Features;
@@ -39,7 +40,8 @@
Route::for('auth/status')
->get([$this, 'getAuthStatus'])
->auth('public')
- ->rateLimit();
+ ->rateLimit()
+ ->register();
// Standard login
Route::for('auth/login')
@@ -51,7 +53,8 @@
'redirect_to' => 'string',
])
->auth('public')
- ->rateLimit(5, 300);
+ ->rateLimit(5, 300)
+ ->register();
// User registration
Route::for('auth/register')
@@ -64,7 +67,8 @@
'redirect_to' => 'string',
])
->auth('public')
- ->rateLimit(3, 3600);
+ ->rateLimit(3, 3600)
+ ->register();
// Request password reset
Route::for('auth/lostpassword')
@@ -73,7 +77,8 @@
'user_email' => 'email|required',
])
->auth('public')
- ->rateLimit(3, 3600);
+ ->rateLimit(3, 3600)
+ ->register();
// Reset password with token
Route::for('auth/resetpass')
@@ -85,7 +90,8 @@
'pass2' => 'string|required',
])
->auth('public')
- ->rateLimit(5, 300);
+ ->rateLimit(5, 300)
+ ->register();
// Magic link endpoint
if ($this->hasMagicLink) {
@@ -97,16 +103,16 @@
'redirect_to' => 'string',
])
->auth('public')
- ->rateLimit(5, 3600);
+ ->rateLimit(5, 3600)
+ ->register();
}
// Logout endpoint
Route::for('auth/logout')
->post([$this, 'handleLogout'])
->auth('logged_in')
- ->rateLimit(10, 60);
-
- error_log('=================== LOGIN ROUTES REGISTERED ===================');
+ ->rateLimit(10)
+ ->register();
}
/**
@@ -335,7 +341,7 @@
'error' => $key->get_error_message(),
]);
} else {
- $this->sendPasswordResetEmail($user, $key);
+ $success = JVB()->email()->sendPasswordResetEmail($user, $key);
}
}
@@ -705,26 +711,6 @@
}
}
- /**
- * Send password reset email (fallback if magic links not available)
- */
- protected function sendPasswordResetEmail(WP_User $user, string $key): bool
- {
- $reset_url = network_site_url(
- "wp-login.php?action=rp&key=$key&login=" . rawurlencode($user->user_login),
- 'login'
- );
-
- $subject = 'Password Reset Request';
- $message = sprintf(
- "Hello %s,\n\nYou requested a password reset. Click the link below to reset your password:\n\n%s\n\nIf you didn't request this, please ignore this email.",
- $user->display_name,
- $reset_url
- );
-
- return wp_mail($user->user_email, $subject, $message);
- }
-
protected function buildAuth(?int $user = null): array
{
if (is_user_logged_in()) {
@@ -754,9 +740,7 @@
if (Features::forSite()->has('favourites')) {
$nonces['favourites'] = wp_create_nonce('favourites-'.$userID);
}
- if (Features::anyContentHas('karma') ||
- Features::anyTaxonomyHas('karma') ||
- Features::anyUserHas('karma')) {
+ if (!empty(Registrar::getFeatured('karma'))) {
$nonces['votes'] = wp_create_nonce('votes-'.$userID);
}
if (Features::forSite()->has('notifications')) {
--
Gitblit v1.10.0