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>
This commit is contained in:
root
2025-11-13 19:10:02 +00:00
parent fc494c1e08
commit 77b4d10af8
28155 changed files with 2191860 additions and 12967 deletions

View File

@@ -5,6 +5,9 @@ namespace App\RSpade\Core\Session;
use RuntimeException;
use App\RSpade\Core\Database\Models\Rsx_System_Model_Abstract;
use App\RSpade\Core\Manifest\Manifest;
use App\RSpade\Core\Models\Login_User_Model;
use App\RSpade\Core\Models\Site_Model;
use App\RSpade\Core\Models\User_Model;
/**
* Session model - handles both authentication sessions and static session management
@@ -24,7 +27,7 @@ use App\RSpade\Core\Manifest\Manifest;
* @property int $id
* @property bool $active
* @property int $site_id
* @property int $user_id
* @property int $login_user_id
* @property int $experience_id
* @property string $session_token
* @property string $csrf_token
@@ -35,8 +38,31 @@ use App\RSpade\Core\Manifest\Manifest;
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
*/
/**
* _AUTO_GENERATED_ Database type hints - do not edit manually
* Generated on: 2025-11-04 07:18:11
* Table: sessions
*
* @property int $id
* @property bool $active
* @property int $site_id
* @property int $login_user_id
* @property mixed $session_token
* @property mixed $csrf_token
* @property mixed $ip_address
* @property mixed $user_agent
* @property string $last_active
* @property int $version
* @property string $created_at
* @property string $updated_at
* @property int $created_by
* @property int $updated_by
* @property int $experience_id
*
* @mixin \Eloquent
*/
class Session extends Rsx_System_Model_Abstract
{
{
// Enum definitions (required by abstract parent)
public static $enums = [];
@@ -45,7 +71,9 @@ class Session extends Rsx_System_Model_Abstract
private static $_site = null;
private static $_user = null;
private static $_login_user = null; // Authentication identity (Login_User_Model)
private static $_user = null; // Site-specific user (User_Model)
private static $_session_token = null;
@@ -63,7 +91,9 @@ class Session extends Rsx_System_Model_Abstract
// CLI mode properties (static-only, no database)
private static $_cli_site_id = null;
private static $_cli_user_id = null;
private static $_cli_login_user_id = null; // Authentication identity ID
private static $_cli_user_id = null; // Site-specific user ID
private static $_cli_experience_id = 0;
@@ -80,7 +110,7 @@ class Session extends Rsx_System_Model_Abstract
protected $casts = [
'active' => 'boolean',
'site_id' => 'integer',
'user_id' => 'integer',
'login_user_id' => 'integer',
'experience_id' => 'integer',
'version' => 'integer',
'last_active' => 'datetime',
@@ -293,7 +323,7 @@ class Session extends Rsx_System_Model_Abstract
self::$_has_set_cookie = false;
// Clear cookie
setcookie('rsx_session', '', [
setcookie('rsx', '', [
'expires' => time() - 3600,
'path' => '/',
'domain' => '',
@@ -350,7 +380,29 @@ class Session extends Rsx_System_Model_Abstract
}
/**
* Get user ID for current session
* Get login user ID (authentication identity) for current session
* In CLI mode: returns static CLI property
* @return int|null
*/
public static function get_login_user_id()
{
// CLI mode: return static property
if (self::__is_cli()) {
return self::$_cli_login_user_id;
}
self::init();
if (empty(self::$_session)) {
return null;
}
return self::$_session->login_user_id;
}
/**
* Get site-specific user ID for current session
* This is the users.id (site-specific), not login_users.id
* In CLI mode: returns static CLI property
* @return int|null
*/
@@ -361,13 +413,9 @@ class Session extends Rsx_System_Model_Abstract
return self::$_cli_user_id;
}
self::init();
$user = self::get_user();
if (empty(self::$_session)) {
return null;
}
return self::$_session->user_id;
return $user ? $user->id : null;
}
/**
@@ -376,46 +424,50 @@ class Session extends Rsx_System_Model_Abstract
*/
public static function is_logged_in(): bool
{
return !empty(self::get_user_id());
return !empty(self::get_login_user_id());
}
/**
* Get user model for current session
* Get login user model (authentication identity) for current session
* @return Login_User_Model|null
*/
public static function get_login_user()
{
$login_user_id = self::get_login_user_id();
if (empty($login_user_id)) {
return null;
}
if (empty(self::$_login_user)) {
self::$_login_user = Login_User_Model::find($login_user_id);
}
return self::$_login_user;
}
/**
* Get site-specific user model for current session
* @return User_Model|null
*/
public static function get_user()
{
$user_id = self::get_user_id();
$login_user_id = self::get_login_user_id();
$site_id = self::get_site_id();
if (empty($user_id)) {
if (empty($login_user_id) || empty($site_id)) {
return null;
}
if (empty(self::$_user)) {
self::$_user = User_Model::find($user_id);
self::$_user = User_Model::where('login_user_id', $login_user_id)
->where('site_id', $site_id)
->first();
}
return self::$_user;
}
/**
* Get site_user model for current session
* @return Site_User_Model|null
*/
public static function get_site_user()
{
$user_id = self::get_user_id();
$site_id = self::get_site_id();
if (empty($user_id) || empty($site_id)) {
return null;
}
return Site_User_Model::where('user_id', $user_id)
->where('site_id', $site_id)
->first();
}
/**
* Get current session model (creates if needed)
* @return Session
@@ -476,22 +528,24 @@ class Session extends Rsx_System_Model_Abstract
*/
public static function logout(): void
{
self::set_user(null);
self::set_login_user_id(null);
}
/**
* Set user for current session
* Set login user ID for current session (login/logout)
* In CLI mode: sets static CLI property only, no database
* @param User_Model|int|null $user User model, user ID, or null to logout
* @param int|null $login_user_id Login user ID, or null to logout
* @return void
*/
public static function set_user($user): void
public static function set_login_user_id(?int $login_user_id): void
{
// Logout if null/0
if (empty($user)) {
if (empty($login_user_id)) {
// CLI mode: clear static property only
if (self::__is_cli()) {
self::$_cli_login_user_id = null;
self::$_cli_user_id = null;
self::$_login_user = null;
self::$_user = null;
self::$_site = null;
@@ -499,32 +553,21 @@ class Session extends Rsx_System_Model_Abstract
}
self::__activate();
self::$_session->user_id = null;
self::$_session->login_user_id = null;
self::$_session->save();
self::$_login_user = null;
self::$_user = null;
self::$_site = null;
return;
}
// Handle different input types
if (is_numeric($user)) {
$user_id = (int)$user;
} elseif (is_object($user)) {
// Try to get the id property (works with Eloquent models via magic method)
if (isset($user->id)) {
$user_id = $user->id;
} else {
throw new RuntimeException('Session::set_user: User object must have an id property');
}
} else {
throw new RuntimeException('Session::set_user: Invalid user parameter');
}
// CLI mode: set static property only
if (self::__is_cli()) {
self::$_cli_user_id = $user_id;
self::$_cli_login_user_id = $login_user_id;
self::$_cli_user_id = null;
self::$_login_user = null;
self::$_user = null;
self::$_site = null;
@@ -538,7 +581,7 @@ class Session extends Rsx_System_Model_Abstract
$new_csrf = bin2hex(random_bytes(32));
self::$_session->session_token = $new_token;
self::$_session->csrf_token = $new_csrf;
self::$_session->user_id = $user_id;
self::$_session->login_user_id = $login_user_id;
self::$_session->version++;
self::$_session->save();
@@ -546,15 +589,16 @@ class Session extends Rsx_System_Model_Abstract
self::$_has_set_cookie = false; // Force new cookie
self::_set_cookie();
// Clear cached user/site
// Clear cached login_user/user/site
self::$_login_user = null;
self::$_user = null;
self::$_site = null;
// Update user's last login
$user_record = self::get_user();
if ($user_record) {
$user_record->last_login = now();
$user_record->save();
// Update login user's last login timestamp
$login_user_record = self::get_login_user();
if ($login_user_record) {
$login_user_record->last_login = now();
$login_user_record->save();
}
}
@@ -564,17 +608,14 @@ class Session extends Rsx_System_Model_Abstract
* @param Site_Model|int $site Site model or site ID
* @return void
*/
public static function set_site($site): void
/**
* Set site ID
* In CLI mode: sets static CLI property only
* @param int $site_id
* @return void
*/
public static function set_site_id(int $site_id): void
{
// Handle different input types
if (is_numeric($site)) {
$site_id = (int)$site;
} elseif (is_object($site) && property_exists($site, 'id')) {
$site_id = $site->id;
} else {
throw new RuntimeException('Session::set_site: Invalid site parameter');
}
// CLI mode: set static property only
if (self::__is_cli()) {
self::$_cli_site_id = $site_id;
@@ -617,28 +658,6 @@ class Session extends Rsx_System_Model_Abstract
return !empty(self::$_session);
}
/**
* Set user ID directly (convenience method)
* In CLI mode: sets static CLI property only
* @param int|null $user_id
* @return void
*/
public static function set_user_id($user_id): void
{
self::set_user($user_id);
}
/**
* Set site ID directly (convenience method)
* In CLI mode: sets static CLI property only
* @param int $site_id
* @return void
*/
public static function set_site_id(int $site_id): void
{
self::set_site($site_id);
}
/**
* Get session by token (for API/external access)
* @param string $token
@@ -679,12 +698,12 @@ class Session extends Rsx_System_Model_Abstract
}
/**
* Relationship: User
* Relationship: Login User (authentication identity)
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
public function login_user()
{
return $this->belongsTo(User_Model::class, 'user_id');
return $this->belongsTo(Login_User_Model::class, 'login_user_id');
}
/**
@@ -697,14 +716,14 @@ class Session extends Rsx_System_Model_Abstract
}
/**
* Relationship: Site_User (composite key relationship)
* Returns the Site_User_Model that matches both site_id and user_id
* Relationship: Site-specific User (composite key relationship)
* Returns the User_Model that matches both login_user_id and site_id
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function site_user()
public function user()
{
return $this->hasOne(Site_User_Model::class, 'user_id', 'user_id')
->where('site_users.site_id', '=', $this->site_id);
return $this->hasOne(User_Model::class, 'login_user_id', 'login_user_id')
->where('users.site_id', '=', $this->site_id);
}
/**