This pull request updates the preRegisterCheck function in the Generate Types extension to be compatible with both Directus 11 and 11.0.2+. The change addresses the relocation of the admin_access property from the user's role to the user object itself in newer Directus versions.
Changes made:
Updated the type definition for the user parameter in preRegisterCheck to include both possible structures:
admin_access directly on the user object
admin_access within the role object
Modified the preRegisterCheck function to check for admin_access in both locations using the nullish coalescing operator (??).
Added a fallback to false if admin_access is not found in either location.
This change ensures backwards compatibility with older Directus versions while supporting the new structure in Directus 11.0.2 and later.
Testing:
Tested with Directus 11.0.2
Verified that the extension works correctly with the new user structure
Ensured backwards compatibility with older Directus versions
Please review and test this change to ensure it meets the requirements for both new and existing Directus installations.
This pull request updates the
preRegisterCheck
function in the Generate Types extension to be compatible with both Directus 11 and 11.0.2+. The change addresses the relocation of theadmin_access
property from the user's role to the user object itself in newer Directus versions.Changes made:
Updated the type definition for the
user
parameter inpreRegisterCheck
to include both possible structures:admin_access
directly on the user objectadmin_access
within therole
objectModified the
preRegisterCheck
function to check foradmin_access
in both locations using the nullish coalescing operator (??
).Added a fallback to
false
ifadmin_access
is not found in either location.This change ensures backwards compatibility with older Directus versions while supporting the new structure in Directus 11.0.2 and later.
Testing:
Please review and test this change to ensure it meets the requirements for both new and existing Directus installations.