Skip to content

MaSys/ms-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ms-auth

Vuejs Authorization

example

import auth from 'ms-auth'

const options = {
  homeRoute: 'home', // route to be redirected when unauthorized
  loginRoute: 'login', // route to be redirected when unauthenticated
  router, // VueRouter instance
  async getCurrentUser () {
    // Fetch user in session information
    return Promise.resolve({ id: 1, email: 'john@doe.com', token: 'aaasdasd' })
  },
  async prepareAcls (auth) {
    // Do your magic here and give the user the rules to access resources.
    auth.addRule('User', 'read')
    auth.addRule('User', 'create')
  },
  async onUnauthorized (auth) {
    auth.logout()
  }
}

// Vue 2.x
Vue.use(auth, options)

// Vue 3.x
createApp(App)
  ...
  .use(auth, options)
  ...

Directive

<router-link v-can:update="'Post'">
  ...
</router-link>

About

Vuejs Authentication & Authorization

Resources

License

Stars

Watchers

Forks

Packages

No packages published