Files
root 77b4d10af8 Refactor filename naming system and apply convention-based renames
Standardize settings file naming and relocate documentation files
Fix code quality violations from rsx:check
Reorganize user_management directory into logical subdirectories
Move Quill Bundle to core and align with Tom Select pattern
Simplify Site Settings page to focus on core site information
Complete Phase 5: Multi-tenant authentication with login flow and site selection
Add route query parameter rule and synchronize filename validation logic
Fix critical bug in UpdateNpmCommand causing missing JavaScript stubs
Implement filename convention rule and resolve VS Code auto-rename conflict
Implement js-sanitizer RPC server to eliminate 900+ Node.js process spawns
Implement RPC server architecture for JavaScript parsing
WIP: Add RPC server infrastructure for JS parsing (partial implementation)
Update jqhtml terminology from destroy to stop, fix datagrid DOM preservation
Add JQHTML-CLASS-01 rule and fix redundant class names
Improve code quality rules and resolve violations
Remove legacy fatal error format in favor of unified 'fatal' error type
Filter internal keys from window.rsxapp output
Update button styling and comprehensive form/modal documentation
Add conditional fly-in animation for modals
Fix non-deterministic bundle compilation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-13 19:10:02 +00:00

104 lines
3.3 KiB
Plaintext
Executable File

<?php
/**
* CODING CONVENTION:
* This file follows the coding convention where variable_names and function_names
* use snake_case (underscore_wherever_possible).
*/
namespace Rsx;
use Illuminate\Http\Request;
use App\RSpade\Core\Base\Main_Abstract;
use App\RSpade\Core\Session\Session;
/**
* Main - Application-wide middleware hooks
*
* Provides application-wide initialization and request lifecycle hooks
*/
class Main extends Main_Abstract
{
/**
* Initialize the Main class
*
* Called once during application bootstrap
*
* @return void
*/
public static function init()
{
// Application initialization logic here
// Example: Log that Main was initialized
// \Log::info('Main::init() called');
Session::set_site_id(1);
}
/**
* Pre-dispatch hook
*
* Called before any route dispatch. If a non-null value is returned,
* dispatch is halted and that value is returned as the response.
*
* @param Request $request The current request
* @param array $params Combined GET values and URL parameters
* @return mixed|null Return null to continue, or a response to halt dispatch
*/
public static function pre_dispatch(Request $request, array $params)
{
// Site locks are now automatically acquired in RsxSession::get_site_id()
// when any code accesses the site_id from the session
// Backdoor authentication for development testing
// Only active in local/development/testing environments
if (in_array(app()->environment(), ['local', 'development', 'testing'])) {
$dev_auth_user_id = $request->header('X-Dev-Auth-User-Id');
if ($dev_auth_user_id) {
// Load RsxAuth and Login_User model - these are core framework classes that must exist
$user_class = 'App\RSpade\Core\Models\Login_User_Model';
$auth_class = 'App\RSpade\Core\Auth\RsxAuth';
// Find the user
$user = $user_class::find($dev_auth_user_id);
if ($user) {
// Bypass normal authentication and login as this user
$auth_class::login($user);
// Log this for debugging
if (config('app.debug')) {
console_debug('AUTH', "DEV AUTH: Authenticated as user {$user->id} via X-Dev-Auth-User-Id header");
}
}
}
}
// Example: Redirect root path to login
// This demonstrates how to globally redirect requests
// Uncomment the following to redirect / to /login:
// if ($request->path() === '/') {
// return redirect('/login');
// }
// Return null to continue normal dispatch
return null;
}
/**
* Unhandled route hook
*
* Called when no route matches the request
*
* @param Request $request The current request
* @param array $params Combined GET values and URL parameters
* @return mixed|null Return null for default 404, or a response to handle
*/
public static function unhandled_route(Request $request, array $params)
{
// Custom 404 handling logic here
// Return null to use default 404 behavior
return null;
}
}