Coder Social home page Coder Social logo

syedpeer / casl-vue-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stalniy/casl-vue-example

0.0 1.0 0.0 134 KB

Example of CASL based auhorization integration with vue

License: MIT License

JavaScript 62.29% HTML 0.67% Vue 34.85% CSS 2.19%

casl-vue-example's Introduction

CASL and Vue integration example

This example shows how to integrate CASL auhorization in Vuejs2 application. Read Vue ACL with CASL for detailed explanation.

Generate with vue-cli

Note: refactored to use CASL 2.0. See @casl/ability and @casl/vue for details.

Installation

# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

Description

This application is a basic Todo application with possibility to specify assignee for a task. By default, all users are able to create and read all tasks but update and delete only assigned to them. Any user may create a task and assign it to other users.

Ability configuration can be found in src/config/ability.js, the Vue plugin for abilities is in src/config/ability-plugin.js. The plugin adds $can (references ability.can) method to every Vue component and make sure that all components are updated when ability.update method is called.

Example

<div class="view">
  <input class="toggle" type="checkbox" v-model="todo.completed" v-if="$can('update', todo)">
  <label @dblclick="$can('update', todo) && editTodo(todo)">{{ todo.title }}</label>
  <button class="destroy" v-if="$can('delete', todo)" @click="removeTodo(todo)"></button>
</div>

Another example: Example of integration CASL with Vuex and REST API

casl-vue-example's People

Contributors

stalniy avatar

Watchers

Syed Peer 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.