# Account Management

#### **Customer Account Creation Process**

The platform provides a **comprehensive customer management** system that handles the creation and management of user accounts, each associated with specific roles and privileges. This process ensures that each customer account is created securely, uniquely identified by email, and integrated into the platform's **Role-Based Access Control (RBAC)** system, assigning them appropriate permissions based on their role.

**Step 1: Initial User Subscription**

The account creation process begins when a **new user subscribes** to the platform by providing their email address. The following mechanisms are employed to ensure the integrity of the user account creation process:

* **Email Uniqueness**: Each subscription attempt is verified for email uniqueness. The platform ensures that only one account can be registered per email address, preventing duplicate registrations.
* **JWT with Email Claim**: Once a user provides their email, a **JWT (JSON Web Token)** is generated with the email embedded as a claim. This token is crucial for tracking the verification process and maintaining a secure, stateless approach to user validation.

**Step 2: Email Validation with OTP**

To verify the user’s identity and secure the account creation process, an **OTP (One-Time Password)** is generated and sent to the provided email address. This OTP is time-sensitive and used for validation purposes. Upon receiving the OTP, the user inputs the code into the platform, confirming the validity of their email.

* **JWT-based Verification**: The platform uses the previously generated JWT to confirm the email. The OTP and the JWT are linked to ensure that only authorized users, who have access to the email, can proceed with the account creation process.

**Step 3: Creation of Default Customer Account**

Once the email is confirmed, the platform creates a **default customer account**. This account serves as the basic foundation for all subsequent user actions:

* **Default Role Assignment**: By default, the account is created with the **User role**, which grants basic access to platform features. However, this role can later be elevated based on the user's needs, such as becoming an **Admin**, **License Owner**, or **Organization Owner**.
* **Role Position**: In addition to the user role, a **RolePosition** is assigned, which could be positions like **Manager**, **Analyst**, or **Compliance Officer**, depending on the user's expected responsibilities.

The customer data is securely stored in the platform, ensuring the uniqueness of the user by enforcing a unique email constraint at the database level.

**Step 4: Completion of Account Registration**

After the default account is created, a **confirmation link** is sent to the user’s email. This confirmation link is embedded with the previously generated JWT and provides the user with access to a form where they can **complete the remaining account fields**. This step ensures that the customer provides all the necessary details required for a fully functional account:

* **Remaining Data Fields**: The user is prompted to fill out additional information, such as their name, password, and specific preferences based on their role within the platform.
* **Optional Role Selection**: At this point, users may choose to specify their **RolePosition** if they belong to a specific organization or wish to assume a managerial role, like **System Administrator**, **Lawyer**, or **Compliance Officer**.

**Step 5: Account Activation & Role-Based Access Control (RBAC)**

Upon successfully completing the registration process, the account is fully activated. The platform’s **RBAC system** enforces strict access control policies based on the user’s role and position:

* **User Roles**:
  * **User**: Has access to general platform features.
  * **Admin**: Has administrative privileges, including user and organization management.
  * **License Owner**: Manages and validates professional licenses.
  * **Organization Owner**: Oversees organizational operations, including license validation.
* **Role Positions**:
  * **Manager**: Oversees team operations and platform workflow.
  * **Compliance Officer**: Ensures the organization adheres to regulations.
  * **Lawyer**: Provides legal counsel for licenses and compliance.
  * **System Administrator**: Maintains IT systems and infrastructure.

With this final step, the user is now a fully registered and verified member of the platform, ready to access the system according to their assigned role and responsibilities.
