How to use the @microsoft/sp-page-context.SPPermission function in @microsoft/sp-page-context

To help you get started, we’ve selected a few @microsoft/sp-page-context examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SharePoint / sp-dev-fx-controls-react / src / controls / securityTrimmedControl / SecurityTrimmedControl.tsx View on Github external
// Check if a result was retrieved
      if (result) {
        // Check if an error was retrieved
        if (result.error) {
          // Do not allow rendering when there was an error
          this.setState({
            allowRender: false
          });
          console.error(`Error retrieved while checking user's remote list or library permissions.`);
          return;
        }

        // Check the result high and low value are returned
        if (typeof result.High !== "undefined" && typeof result.Low !== "undefined") {
          // Create the permission mask
          const permission = new SPPermission(result);
          const hasPermissions = permission.hasAllPermissions(...permissions);

          this.setState({
            allowRender: hasPermissions
          });
          return;
        }
      } else {
        this.setState({
          allowRender: false
        });
        console.error(`No result value was retrieved when checking the user's remote list or library permissions.`);
        return;
      }
    }
  }

@microsoft/sp-page-context

Page context services for the SharePoint Framework

https://aka.ms/spfx/license
Latest version published 3 months ago

Package Health Score

66 / 100
Full package analysis

Similar packages