0.0.8 • Published 7 years ago

@kailight/tribefire-auth v0.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

@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)
  }
}
0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago