User Permission

From Documentation
Revision as of 04:33, 11 April 2019 by Hawk (talk | contribs) (→‎Overview)




Overview

One of the most concerned issues is access control for ZSS. We think most enterprises have its own authorization rule. ZSS doesn't have its own authorization and authentication features. Instead, it provide 3 categories of API to help you build your own user permission mechanism:

  • show/hide UI
  • enable/disable functions
  • sheet protection


We will demonstrate the usage of API with a simple application. In this application, you can login with 3 different roles: OWNER, EDITOR, VIEWER. Their permissions are described in the image below:

Zss-essentials-login.png

If you login as an owner, you will have full control of the file. But if you login as an editor, you will find all sheet related operations are disabled.

Zss-essentials-editor.png


When you login as a viewer, the only thing you can do is viewing. Because there is no UI for edit, and all sheets are protected from editing.

Zss-essentials-viewer.png


This application relies on those API we mentioned in previous chapters to control the access for each role. Let's recap them here:

Hide User Interface

Working with Spreadsheet/Control Components

Example:

spreadsheet.setShowToolbar(false);

Disable Functions

Working with Spreadsheet/Advanced/Disable Functions

Example:

spreadsheet.disableUserAction(AuxAction.COPY_SHEET, true);

Protect a Sheet

Working with Spreadsheet/Handling Data Model/Protection

Example:

Ranges.range(spreadsheet.getSelectedSheet()).protectSheet("password",
                true, true, false, false, false, false, false,
                false, false, false, false, false, false, false, false);


You can download the example source code to know the complete implementation.



All source code listed in this book is at Github.


Last Update : 2019/04/11

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.