Skip to content

Refactor: Improve project structure and refactor registerIdentity#1766

Open
rwixy wants to merge 4 commits into
esx-framework:devfrom
rwixy:esx-identity
Open

Refactor: Improve project structure and refactor registerIdentity#1766
rwixy wants to merge 4 commits into
esx-framework:devfrom
rwixy:esx-identity

Conversation

@rwixy

@rwixy rwixy commented Dec 7, 2025

Copy link
Copy Markdown

Description

This pull request refactors esx_identity by modularizing the codebase, improving the structure, and applying the DRY principle.
The esx_identity:registerIdentity callback has been cleaned up and optimized, and related logic has been moved into dedicated files for better maintainability.

PR Checklist

  • My commit messages and PR title follow the Conventional Commits standard.
  • My changes have been tested locally and function as expected.
  • My PR does not introduce any breaking changes.
  • I have provided a clear explanation of what my PR does, including the reasoning behind the changes and any relevant context.

@ASTROWwwW

ASTROWwwW commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Nice cleanup — the modular split makes esx_identity much easier to follow. Two things worth a look:

1. completeRegistration now fires esx_identity:completedRegistration in the standalone path too. In the current main.lua, esx_identity:completedRegistration is triggered only in the multichar branch (xPlayer == nil). Here Callback.RegisterIdentity calls the shared completeRegistration() in both branches, so a normal non-multichar registration now also emits that event. Anything subscribed to it (esx_multicharacter, third-party resources) will start receiving it in standalone mode — intended, or should completeRegistration skip the event in the xPlayer branch to keep the previous behavior?

2. Two existing gaps you could close while you're in this code:

  • validateRegistrationData reads data.firstname directly, so a client triggering esx_identity:registerIdentity with a non-table data throws and aborts the callback — a type(data) ~= 'table' guard at the top of Callback.RegisterIdentity covers it.
  • CheckSexFormat accepts "M"/"F" but getFormattedIdentity stores data.sex raw, so "M" gets persisted and breaks downstream sex == "m" checks; lowercasing before save fixes it.

(I have those two in #1787 against main — happy to fold them into validation.lua/callback.lua here instead.)

Minor: registry.lua makes Modules a global; a local returned/exported from the module would avoid the global and the implicit fxmanifest load-order coupling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants