Skip to main content

Privileges

Overview

The purpose of this tutorial is to implement a new POS function that is protected by privileges. The tutorial will simulate a new POS function, first checking that the user is allowed to run the function and second checking that the user is authorised to run it. If the currently logged-in user is not authorised, this tutorial will show how to ask a different user to log in temporarily in order to authorise the function. This is the general flow that an Enactor POS function follows.

What You Will Learn

  • How to create new privileges and register them
  • How to validate whether the current user has a given privilege
  • How to trigger authorisation from a different user

Prerequisites

  • Familiarity with creating Application Processes and using them as Application Process Extensions.
  • Understanding of how privileges are configured in Enactor
  • EM should be up and running

Instructions

Create a Process Extension

Bring up the Resource Library view and search for the process HandleFunctions2.

Select and open HandleFunctions2_1.0.xml.

Search For HandleFunctions2

Using the Outline view, expand the Actions group and search for CallHandleFunction2Extension.

SearchForCallHandleFunction2Extension

Double-click on CallHandleFunction2Extension, then click Create New Extension Process in the wizard that opens.

Select Extension View

Enter the Extension Name as Pos Function With Privilege Extension and the Process ID as Pos/Training/PosFunctionWithPrivilege, then click Browse to set the container.

Extension Point Wizard

Select the Process in the TrainingPOSExtension folder and click OK.

Folder Selection Extension

Click Finish to complete.

Extension Point Settings Finish

  • Open the newly created Pos/Training/PosFunctionWithPrivilege application process:
    • Add a starting state with the StateEntered event.

    • Drop com.enactor.coreUI.actions.CheckEventAction from the Resource Library.

    • Add the WithPrivilegeEvent and Unknown events as outcomes of the action and name it CheckEvent.

    • Add an Unknown outcome.

    • The Unknown event should then be linked to an outcome of Unknown.

    • Drag the CurrentEvent input of the CheckEventAction onto the Inputs of the Process. When a POS function is triggered from the Sales menu, the extension will be called with CurrentEvent set to the event configured in the menu.

      CopyCurrentEventToProcessInput.png

    • Add Execute Process from Advanced Actions in the Palette.

Add Execute Process.png

  • Configure the Execute Process action with the following settings:

    FieldValue
    Class Namecom.enactor.coreUI.actions.CallProcessWithPrivilegesAction
    Execute Process IDPos/SignOn/CheckAuthorisation
    Privilegesenactor.training.AuthoriseWithPrivilegeEvent
  • Once it has been added, double-click on the CallProcessWithPrivilegesAction and click Configure Mapping in the Unable to find Process popup.

Unable To Find Process

  • Select the C:\User\EnactorAdmin\.m2\repository\com\enactor\pos\pos\...., then click OK.

Configure Resource Mappings

  • Pos/SignOn/CheckAuthorisation is now accessible and can be opened without any issues when double-clicking on CallProcessWithPrivilegesAction.

  • Add a Message State, set the Message ID to AuthorisedUser and the Message Base to TrainingPOSExtension/TrainingPOSExtensionMessages, then route the success outcome from CallProcessWithPrivilegesAction to this state.

Add MessageState

  • Add the OKPressed event and route the link to the BackToSale end process.

CompleteProcess

Add the Privilege to the Message Resource

Add the following parameters to TrainingPOSExtensionMessages.xml:

<ns2:message key="enactor.training.AuthoriseWithPrivilegeEvent.Name">Authorise With Privilege Event</ns2:message>
<ns2:message key="enactor.training.AuthoriseWithPrivilegeEvent.Description">Training privilege for authorising a POS function event</ns2:message>
<ns2:message key="AuthorisedUser">Authorised User</ns2:message>

Add a new button to the POS menu

Log in to the EM.

The Menus Maintenance function is accessed using the search or path: Configuration > System > Menus

Menus Maintenance Path

  • Add the filter values Menu Group as Default Standard POS and Menu ID as SALE, then edit the filtered entry.

    Menus Filter

  • Expand Sales, Loyalty will be displayed inside

    Sale Menu Tree

  • Select Loyalty and press the Add... button, then select Add a new Button.

    Add New Button

  • Add the new button with the event WithPrivilegeEvent.

    Add WithPrivilegeEvent Button

Enable the Privilege for a Specific Role

  • Log in to the EM.

  • The JAR of the TrainingPOSExtension needs to be deployed using the JAR Deployer from the EM for the newly added privilege to appear in the list.

The JAR Deployer Maintenance function is accessed using the search or path:

Administration > Data Management > JAR Deployer

JAR Deployer navigation path in Estate Manager

info

Since the same database is shared between the POS and the EM in the developer setup, and the TrainingPOSExtension changes are on the classpath, restarting the POS will automatically deploy the packages. The newly added privilege will then be visible in the EM.

The User Roles Maintenance function is accessed using the search or path: Configuration > HR > User Roles

User Role Maintenance Path

  • Add the filter value User Role ID as SALES_ASSISTANT, then edit the filtered entry.

User Role Filter

  • Select the Application Package as TrainingPOSExtension and enable or disable the enactor.training.AuthoriseWithPrivilegeEvent privilege.

EnablePrivilege

  • Without privilege — The authorisation page will be displayed when the With Privilege Event button is pressed.

With Out Privilege

  • With privilege — A message will pop up; once the OK button is pressed, the user will be redirected to the sale prompt.

With Privilege