Skip to content

Commit

Permalink
docs(feat): added dev and enduser docu
Browse files Browse the repository at this point in the history
  • Loading branch information
jjeroch authored and evegufy committed May 27, 2024
1 parent 95b150c commit a9659ba
Show file tree
Hide file tree
Showing 2 changed files with 164 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
## Decline Registration Feature Documentation

### Summary

This feature provides users with the ability to decline a registration invite and to remove their account from the CX Database.

### Frontend Implementation

#### Page: `/decline`

##### Logic

When a user receives an invitation email, a "decline" hyperlink is included. Clicking on this hyperlink redirects the user to the `/decline` page. The user must log in before they can delete their account.

##### Happy Path

1. **Page Rendering**: When navigating to `/decline`, the user should see the page as designed (refer to the provided screenshot).

2. **Content Display**: The displayed description on this page must include the company name, the user's name, and all linked usernames of the company.

3. **Page Accessibility**: The page should only be displayed if the company registration is in any of the following states:
- `CREATED`
- `ADD_COMPANY_DATA`
- `INVITE_USER`
- `SELECT_COMPANY_ROLE`
- `UPLOAD_DOCUMENTS`
- `VERIFY`

If the registration does not meet these prerequisites, the alternative flow described in "In case the registration pre-requisite is not fulfilled" should be followed.

4. **Account Deletion**:
- Upon clicking "delete my company", the endpoint `xxxx` (implemented as part of CPLP-3548) is called.
- While the endpoint is processing, the "delete my company" button shows a loading element and cannot be retriggered by the user.

5. **Deletion Success**:
- If the endpoint responds with success, a confirmation screen is shown to the user (refer to the provided screenshot).

6. **Deletion Error**:
- If the endpoint responds with an error, an error screen is displayed.
- Users can attempt to retrigger the deletion process from this screen.

#### In Case the Registration Pre-requisite is Not Fulfilled:

1. If the user's registration status does not match the expected states, they are blocked from declining and presented with a screen that includes a hyperlink to `/home`.

### Backend Implementation

#### Summary

The backend should support the ability for companies in the "registration" status to decline the registration process. This involves setting various records to "deleted" or "declined" and removing users and realms from Keycloak.

#### Suggested API Endpoint

`POST /api/registration/application/{applicationId}/declineRegistration`

##### Business Logic

- Set the company record related to the application as `deleted` in the `portal.companies` table.
- Set the invitation related to the application ID as `declined` in the `portal.invitations` table.
- Set all identities related to the specific application as `deleted` in the `portal.identities` table.
- Set the company application status to `declined` in the `company_applications` table.
- Any documents uploaded for the specific company in the `documents` table should be set to `INACTIVE`.

##### Validation

- Acting user must be assigned the role of `company Admin`.
- Must belong to the registration/application company.
- Application must be in one of the following statuses:
- `CREATED`
- `ADD_COMPANY_DATA`
- `INVITE_USER`
- `SELECT_COMPANY_ROLE`
- `UPLOAD_DOCUMENTS`
- `VERIFY`

#### Keycloak Removal Process

After the above steps, the user and company realm need to be removed from Keycloak. This involves:

- User deletion on both central and shared IdP.
- Realm deletion on shared IdP.
- Identity provider deletion on central IdP.

##### Handling Failures and Retries

Ensure proper handling of potential Keycloak failures, such as Keycloak being down. Coordinate with the designated contact (e.g., Norbert) to establish procedures for manual retriggers, automatic retries, and error handling.

#### Backend Job Order

##### #1 Portal DB Updates

- Set records to `INACTIVE` or `DECLINED` as outlined above.

##### #2 Keycloak DB Deletion

- SharedIdP => Delete company realm (with specific error handling rules)
- SharedIdP => Delete the realm service account
- CentralIdP => Delete "shadow" user record
- CentralIdP => Delete Identity Provider record

##### #3 Portal DB Finalization

- Set company record to `DELETED`.
- Set all identities to `DELETED`.

#### Note

Ensure that all users connected to the company account are updated accordingly when modifying the `identities` table.

<br>

## NOTICE

This work is licensed under the [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0).

- SPDX-License-Identifier: Apache-2.0
- SPDX-FileCopyrightText: 2024 Contributors to the Eclipse Foundation
- Source URL: https://github.com/eclipse-tractusx/portal-assets
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
## User Guide: How to Decline a Registration Invite

### Introduction

This guide explains how to decline a registration invite and permanently delete your user account from the CX Database.

### Declining Registration

#### Step 1: Accessing the Decline Page

When you decide to decline the registration invite, click on the "decline" hyperlink provided in the invitation email. This link will redirect you to the `/decline` page.

#### Step 2: Logging In

Before you can proceed with declining the registration, you will be asked to log in to confirm your identity.

#### Step 3: Declining the Invite

Once logged in, you will be presented with a page that includes the details of your company and associated users. To proceed with the deletion of your company account, follow these steps:

1. **Confirm Deletion**: Read the information carefully to ensure that you understand the implications of deleting your company account.
2. **Delete Account**: Click on the "delete my company" button to initiate the deletion process.

#### Step 4: Deletion Process

After clicking the deletion button, the system will process your request. During this time, the button will display a loading indicator, and you will not be able to click it again until the process is either completed or an error occurs.

#### Step 5: Confirmation or Error Handling

- **Successful Deletion**: If the account is successfully deleted, a confirmation screen will appear, indicating that the process is complete.
- **Error**: If there is an error in the deletion process, an error screen will be presented. You can attempt to delete the account again from this screen.

### Important Considerations

- The decline option is only available if your company's registration is in one of the following statuses: `CREATED`, `ADD_COMPANY_DATA`, `INVITE_USER`, `SELECT_COMPANY_ROLE`, `UPLOAD_DOCUMENTS`, `VERIFY`. If your registration status does not match these, you will be directed to a different screen and provided with a link to return to the `/home` page.
- Make sure you have the necessary permissions (company Admin role) to perform the deletion.

<br>

## NOTICE

This work is licensed under the [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0).

- SPDX-License-Identifier: Apache-2.0
- SPDX-FileCopyrightText: 2024 Contributors to the Eclipse Foundation
- Source URL: https://github.com/eclipse-tractusx/portal-assets

0 comments on commit a9659ba

Please sign in to comment.