3.0.17 • Published 3 years ago

sx-licensing-manager v3.0.17

Weekly downloads
39
License
-
Repository
-
Last release
3 years ago

📖 Implementation

Copy the following code in the entry point of your application for example: main.ts or main.js.

import useLicesingManagerAdapter from "sx-licensing-manager";

useLicesingManagerAdapter(Vue, {
  applicationId: 'your application id',
  applicationServer: 'the server of the Licensing API',
})

Your entry point should look like this:

import Vue from 'vue'
import App from './App.vue'
import useLicesingManagerAdapter from "sx-licensing-manager";

Vue.config.productionTip = false

useLicesingManagerAdapter(Vue, {
  applicationId: 'your application id',
  applicationServer: 'the server of the Licensing API',
})

new Vue({
  render: h => h(App),
}).$mount('#app')

🔥 Usage

Where validate the user who will log in:

    this.templateIsReady = await this.$sxLicesingManager.setLicensingPermissions(user) 

Create the variable templateIsReady and do not condition the render of the app with this

    <template v-if="templateIsReady"> 
      <nav-bar />
      <div class="columns" id="mail-app">
        <side-bar />
        <div class="column is-10 messages hero is-fullheight">
          <div class="card gray-container">
            <div class="card-content">
              <router-view></router-view>
            </div>
          </div>
        </div>
      </div>
    </template>

In your vue template you need to put the directive licensing-permission and the function code declared in SX-Licensing-Manager as parameter

<template>
  <div>
    <router-link licensing-permission="'your function code'" to="/user" class="item">
        <span class="icon">
            <i class="fa fa-users"></i>
        </span>
        <span class="name">Usuarios</span>
    </router-link>
  </div>
</template>

In the case of wanting to validate the permissions from the code

public myFunction(): void {
    if (this.$sxLicesingManager.hasLicensingPermission('your function code')) {
        console.log('I am cool');
    } else {
        console.log('you does not have permission');
    }
}

In the prototype $sxLicesingManager we have: hasLicensingPermission, setLicensingPermissions, getLicensingPermissions

Note

if you use typescript be sure to add the typing

declare module 'vue/types/vue' {
  interface Vue {
    $sxLicesingManager: any
  }
}
3.0.17

3 years ago

3.0.16

3 years ago

3.0.15

3 years ago

3.0.12

3 years ago

3.0.10

3 years ago

3.0.11

3 years ago

3.0.14

3 years ago

3.0.8

3 years ago

3.0.9

3 years ago

3.0.4

3 years ago

3.0.3

3 years ago

3.0.7

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.0.0

3 years ago

1.0.20

3 years ago