Giter VIP home page Giter VIP logo

wn-permissions-plugin's Introduction

Permissions

Front-end user permissions management.

Composer installation

composer require sunlab/wn-permissions-plugin

Requirements

This plugin requires the Winter.User Plugin.

Creating Permissions

In the backend, navigate to Winter "Users" menu, on the left side there should be an open lock icon with the name "Permissions". Click this, and it will take you to the list of permission.

  • Click "New Permission" to get to a form where you can enter information about a new permission you would like to create.
  • Click on a permission in the list to manage existing permissions.

Managing User Permissions

In the backend, navigate to Winter "Users" menu, now on a User model updating page, you can manage his permission at his user-level.

Managing Group Permissions

In the backend, navigate to Winter "Users" menu, into the side menu, select Groups. Now on a Group model updating page, you can manage the permissions that will be granted for every User in that group.

Using Permissions in your own development

Since every user model is now extended with the hasUserPermission method, it is available in both twig and backend php i.e.

For Twig

{% if user.hasUserPermission(['can-eat-cake', 'can-take-cheese']) %}
    <p>This user has all above permissions</p>
{% else %}
    <p>This user does not have permission</p>
{% endif %}

{% if user.hasUserPermission(['can-eat-cake', 'can-take-cheese'], 'one') %}
    <p>This user has one of the above permissions</p>
{% else %}
    <p>This user does not have permission</p>
{% endif %}

For Backend

if ($user->hasUserPermission(['can-eat-cake', 'can-take-cheese'])) {
    // This user has all above permissions
} else {
    // This user does not have permission
}

if ($user->hasUserPermission(['can-eat-cake', 'can-take-cheese'], 'one')) {
    // This user has one of the above permissions
} else {
    // This user does not have permission
}

wn-permissions-plugin's People

Contributors

romainmazb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.