System Permission and Permission Sets

Options

Hi everyone,

I am developing a SaaS app using Xano and WeWeb. I want to know what the best practice is for establishing a module-based permission system. From a business perspective, customers will be able to choose different package options (basic, full, premium), and each of these packages will have different modules and submodules. Customers should also be able to customize their package by adding or removing modules and submodules. I would like to know if anyone has developed something similar and what would be a good practice for doing this while maintaining flexibility when enabling or disabling these submodules and modules for customers.

Tagged:

Answers

  • Lachlan
    Lachlan Administrator

    ADMIN

    Options

    Hi there, thanks for the question! The below might help point you in the right direction. Please note I haven't personally implemented this, so please use this as general information to test.

    1. Database Design:

    1.1 Users Table:

    • userID (Primary Key)
    • username
    • password
    • email
    • other relevant user info...

    1.2 Packages Table:

    • packageID (Primary Key)
    • packageName (e.g., basic, full, premium)
    • packageDescription
    • packagePrice

    1.3 Modules Table:

    • moduleID (Primary Key)
    • moduleName
    • moduleDescription

    1.4 SubModules Table:

    • subModuleID (Primary Key)
    • subModuleName
    • moduleID (Foreign Key) - to which main module this submodule belongs
    • subModuleDescription

    1.5 User_Packages Table (Mapping table for user's chosen package):

    • userPackageID (Primary Key)
    • userID (Foreign Key)
    • packageID (Foreign Key)

    1.6 User_Modules Table (Mapping table for user's custom modules):

    • userModuleID (Primary Key)
    • userID (Foreign Key)
    • moduleID (Foreign Key)

    1.7 User_SubModules Table (Mapping table for user's custom submodules):

    • userSubModuleID (Primary Key)
    • userID (Foreign Key)
    • subModuleID (Foreign Key)

    1.8 Package_Modules (Mapping table for default modules in a package):

    • packageModuleID (Primary Key)
    • packageID (Foreign Key)
    • moduleID (Foreign Key)

    1.9 Package_SubModules (Mapping table for default submodules in a package):

    • packageSubModuleID (Primary Key)
    • packageID (Foreign Key)
    • subModuleID (Foreign Key)

    2. Business Logic:

    2.1 Assigning Packages:

    • When a user selects a package, the default modules and submodules related to that package are fetched from the Package_Modules and Package_SubModules tables.
    • These modules and submodules are then added to the User_Modules and User_SubModules tables for that user.

    2.2 Customizing Packages:

    • Users can add a module or submodule. This is done by inserting a new row in the User_Modules or User_SubModules table.
    • Users can remove a module or submodule. This is done by deleting the relevant row from the User_Modules or User_SubModules table.

    2.3 Checking Permissions:

    • When a user tries to access a module or submodule, the system checks the User_Modules and User_SubModules tables to see if the user has the necessary permissions.

    3. Flexibility:

    The above design allows for:

    • Easy addition of new modules or submodules.
    • Customization of packages by users.
    • Scalability, as new packages can be easily introduced.

    4. Conditional Visibility


    Depending on the user's permissions (fetched from Xano), you can conditionally show or hide specific modules or submodules in the UI in Weweb.

    Hope that helps!