Kony Fabric console User Guide: Identity > Configure the Identity Service > Using Groups in an App

Using Groups in an App

You can now create groups by using User Repository identity service. Admins and Members are the default groups available in the User Repository identity service. Users can create custom groups as well. When a user is added, the user must be part of a group. By default, all users are associated to the Members group.

Based on the groups you create in User Repository and the response in identity service, you can now directly handle your logic/code in controllers created in MVC (modules in non-MVC) platform, for apps. Your logic/code can include selected functionality targeted to a specific set of users in a group.

Note: For configuring groups for other identity service types, refer Groups Support for Identity Services.

Use Case

To understand the functionality of Groups feature, let us take an example of the sample app KonyEmployeeDirectory. You will learn how to handle groups to authenticate CRUD operations in user forms in the app.

How to Use Groups in Apps (Based on Sample App - KonyEmployeeDirectory)

  1. Import the KonyEmployeeDirectory app into your project in Kony Visualizer.
  2. Navigate to app to the Kony Fabric services by using the Data panel.

    By default, Kony User Repository (Userstore) identity service is linked to the app.

  3. Create a user (User1) and associate the user to the default group Member.
  4. Create another user (User2) and add the user to the new group Admin.

    Sample Test Response:

     {
    "profile": { "userid": "User1@kony.com", "email": "User2@kony.com", "firstname": "User_Admin", "lastname": "Das", "user_attributes": { "user_id": "User1@kony.com", "groups": [ "Admin" ] }, "profile_attributes": },}
  5. In Kony Visualizer, link the Kony Fabric app to your project.
    1. Open the project.
    2. Navigate to Responsive Web/Desktop > Forms, and right-click frmLogic.
    3. Click Navigate to Controller.

      The frmLoginController module is selected. The frmLoginController details sample code to fetched groups details that you configured in Kony Fabric User Store:

      Sample Code Description

      if (result.group[i]=="Admin")kony.store.setItem("isAdmin", true);

      The Admin is the group in User Repository, which can contain users. You can write your logic to allow these users to perform CRUD operations in the Admin app version.

      • In this case, (result.group[i]=="Admin"),
        the logic checks if the result in the response from user repository contains Admin under the groups tag,
      • In this case: (kony.store.setItem("isAdmin", true),
        if you set the group is true, the group details are stored in the array: group[i]
  6. Navigate to Responsive Web/ Desktop > Forms, and right-click frmEmpDetails. The frmEmpDetailsController module contains your code/logic to access CRUD operations than the user (Admin) is authorized to perform, such as view user details, create a new, update user details, and delete a user.

  7. Build the app.

 

 

Copyright © 2020 Kony, Inc. All rights reserved.