Skip to content
This repository was archived by the owner on Jan 31, 2025. It is now read-only.
This repository was archived by the owner on Jan 31, 2025. It is now read-only.

Is there a way to create custom perimeter for custom roles #45

@kavin404

Description

@kavin404

I have a nuxt application where a user can create custom roles. e.g CustomRoleA , CustomRoleB etc. Is there a way to handle this using vue-kindergarten. Is there a way to generate the perimeters dynamically?

import { Perimeter } from 'vue-kindergarten'
export default class BasePerimeter extends Perimeter {
  isSuperAdmin () {
    return this.child === 'SuperAdministrator'
  }

  isPartyAdmin () {
    return this.child === 'PartyAdministrator'
  }

  isTeamAdmin () {
    return this.child === 'TeamAdministrator'
  }

  isPartyUser () {
    return this.child === 'PartyUser'
  }
}


import BasePerimeter from './base'

    export default new BasePerimeter({
      purpose: 'user',

      can: {
        read: () => true,

        add () {
          return this.isSuperAdmin() || this.isPartyAdmin() || this.isTeamAdmin()
        },

        update () {
          return this.isSuperAdmin() || this.isPartyAdmin() || this.isTeamAdmin()
        },

        allowDelete () {
          return this.isSuperAdmin() || this.isPartyAdmin() || this.isTeamAdmin()
        },
        changePassword () {
          return this.isSuperAdmin() || this.isPartyAdmin() || this.isTeamAdmin()
        }
      }
    })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions