Synchra.24
menu_bookDocumentation
Practical guides for setup and development

Find guides for getting started, building workflows and adding your own tools to your company workspace.

folderEmbedded services

Their roles

How to create your own access rights for internal services.

Machine translation

Custom roles in Synchra.24 for internal services are built through application rights. This is a separate set of permissions that is needed not for the basic screens of the platform, but for your embedded services and microapplications.

The idea is simple:

  • you create your own access rights;
  • adding him to the employee role;
  • inside your service, you read the list of rights from the provider's context;
  • Based on this list, you can show or hide actions, sections, and scenarios.

What exactly is being created

The mobile app has a separate section where you can create your access rights for embedded services and microapplications.

Each such right has two fields:

  • Title — a human-readable name that administrators see when setting up roles;
  • Key — the technical name of the right to be used in the application logic.

Example:

  • Title: Управление заявками подрядчиков
  • Key: contractor_requests_manage

Where is it used

After creation, the right appears in the role settings in the section Applications. This means that the administrator can:

  • open role editing;
  • find the authority block for embedded services;
  • enable or disable your right for a specific role.

That is why application rights are convenient to use for scenarios where you need to subtly divide access within your own service.:

  • viewing and editing different entities;
  • access to individual tabs;
  • publication, approval, deletion;
  • launching internal operations only for a part of the employees;
  • separation of rights between line employees, supervisors, and administrators.

How to create a right through the interface

The following is the most direct scenario if you configure access without the platform administrator code.

Step 1. Open the Application Rights section

Inside the desired company, open the screen where they are configured application rights. This is a separate list of all user rights that apply specifically to your services.

Step 2. Click the add button

In the upper-right corner, click add.

After that, a form for creating a new right will open.

Step 3. Fill in the name

In the name field, specify a clear name, which will then be visible when configuring roles.

Good examples:

  • Редактирование заявок подрядчиков
  • Согласование выездов
  • Просмотр финансового отчета

The name should be written so that the role administrator immediately understands what exactly allows this right.

Step 4. Fill in the key

Specify a short technical key in the second field.

For example:

  • contractor_requests_edit
  • trip_approve
  • finance_report_view

This particular key will then be sent to your embedded service in the list of user rights.

Step 5. Save the right

After saving, the new right will appear in the general list of application rights.

At this stage, it has already been created, but still not a single role has been assigned.

Step 6. Go to the roles

Open the Roles screen and select the role to grant access to.

Inside role editing, find the section Applications. The rights created specifically for embedded services are displayed there.

Step 7. Enable the required right for the role

Find your right by name and enable it for the required role.

For example:

  • for an ordinary employee, you can only enable viewing;
  • for a senior employee — viewing and editing;
  • for the supervisor — viewing, editing and approval.

Step 8. Check access inside the service

After that, the user with the selected role will be able to open the service, and inside the application you will be able to check for this right and show the necessary actions.

Key Restrictions

The key field is checked using a template:

^[a-z_]+$

In other words, only allowed in the key:

  • lowercase Latin letters;
  • symbol _.

Suitable examples:

  • requests_view
  • requests_edit
  • warehouse_admin
  • service_publish

Unsuitable examples:

  • RequestsView
  • service-edit
  • service.1
  • роль_админа

We recommend that you agree on a common naming style. Keys in the format usually work best.:

<сервис>_<сущность>_<действие>

For example:

  • contractor_requests_view
  • contractor_requests_edit
  • contractor_requests_approve

What does the lifecycle look like?

1. Create the application right

In the section Application Rights create a new key:

  • enter a clear name;
  • set a technical alias;
  • save the right.

2. Add the right to the role

Open role editing and enable this right in the section Applications.

3. Get rights inside your service

In an embedded application, use the provider context from @synchra24/app:

const provider = await synchra.getProviderContext();

console.log(provider.role.permissions);

In provider.role.permissions You will receive an array of strings containing your custom keys.

4. Apply them in the interface

Verification example:

const provider = await synchra.getProviderContext();

const canEditRequests = provider.role.permissions.includes(
  'contractor_requests_edit'
);

if (canEditRequests) {
  // показываем кнопку редактирования
}

When it makes sense to create your own rights

Use custom rights if the service has at least one of the scenarios:

  • some users should only view the data;
  • some users have to edit the data;
  • only managers can coordinate or publish;
  • different roles should have access to different tabs.;
  • there are administrative and routine actions in one service.

If all employees have the same access and no role logic is required, you don't need to create separate rights.

Recommended rights scheme

For a new service, it is convenient to set multiple access levels at once.:

  • service_view
  • service_edit
  • service_approve
  • service_admin

Then the role can be assembled flexibly.:

  • to the employee — only view;
  • to a senior employee — view + edit;
  • to the manager — view + approve;
  • The administrator is provided with a complete set.

Search and maintenance

Screen CustomPermissions supports:

  • search for created rights;
  • sorting;
  • editing existing keys;
  • removing unnecessary rights.

This is convenient if you already have several services and you are getting a lot of rights.

Practical advice

Don't create too general keys like:

  • admin
  • editor
  • manager

It is better to make the keys subject-specific and linked to a specific service. Then:

  • easier to read the role configuration;
  • it's easier to maintain logic in the code.;
  • The risk of conflicts between different internal services is lower.

Well:

  • inventory_writeoff_edit
  • inventory_writeoff_approve
  • vendor_orders_view

Badly:

  • edit
  • admin_role
  • service_access

What is important to remember

  • Application rights are created separately from the standard system permission of the platform.
  • They are designed specifically for your embedded services.
  • The user does not get the right automatically just because the service is open in the company — the right must be explicitly added to the role.
  • The access logic inside your service's interface is implemented on your side via provider.role.permissions.

What's next

After setting up your own rights, the next step is usually to:

  1. the structure of roles and access scripts;
  2. user rights checks in the interface;
  3. hiding or blocking actions without the necessary permission;
  4. separation of API operations by roles, if required on the server.

If you're just starting out, it's worth going through first.:

  • Quick start — to raise your own service;
  • Bridge library — to understand how to get the provider context and work with the integration SDK.