@kailight/tribefire-auth
v0.0.8
Published
Tribefire-auth VUEX addon
Downloads
1
Readme
@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)
}
}