@kailight/tribefire-auth

0.0.8 • Public • Published

@kailight/tribefire-auth

VUEX addon for loggin in with tribefire-backend

Installation

npm i @kailight/tribefire-auth

Example usage

in your store.js

// don't forget the trailing slash
let BASE = 'http://localhost:3000/'

import axios from 'axios'
const BACKEND = axios.create({
  baseURL : BASE,
  withCredentials: true,
})

import tribefireAuthInit from '@/kailight/tribefire-auth'
let TribefireAuth = tribefireAuthInit(BACKEND)

then

const store = new Vuex.Store({
  state: {
    ...TribefireAuth.state,
    // your state vars
  },
  getters: {
    ...TribefireAuth.getters,
    // your getters
  },
  mutations: {
    ...TribefireAuth.getters,
    // your mutations
  },
  mutations: {
    ...TribefireAuth.getters,
    // your mutations
  },

Usage

Login User

store.dispatch('login', 'login', 'password').then( 
  response => { alert('logged in') } 
)

Register User

store.dispatch('register', 'login', 'password').then( 
  response => { alert('registered') } 
)

Get user data in component

computed : {
  ...mapGetters(['User']),
  // other computed properies
}
...
methods : {
  greetUser() { 
    alert("Hi "+this.User.name)
  }
}

Readme

Keywords

Package Sidebar

Install

npm i @kailight/tribefire-auth

Weekly Downloads

1

Version

0.0.8

License

MIT

Unpacked Size

9.66 kB

Total Files

5

Last publish

Collaborators

  • kailight