1.1.2 • Published 7 years ago

vue-token-fix v1.1.2

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

Vue-Token

Simple token storage/ authorization in vuejs.

This plugin requires you to initialize the vue-resource plugin first.

The token will be stored into the Authorization header with each request you make with the vue-resource plugin.

npm install vue-token-fix --save

Usage

import Auth from "vue-token-fix";
Vue.use(Auth, options);

Options

{
	loginUrl: "/api/login", 
	signupUrl: "/api/users", 
	logoutUrl: "/api/logout"
	refresh: false // Utalize the automatic refresh of tokens (it will use the token from response.token as the new token)
}

Example Component

<script>
export default {
	data(){
		return {
			input: {
				email: "",
				password: ""
			}
		}
	},
	created(){
		//
	},
	methods: {
		send() {
        	this.$auth.login(this, this.input, "profile/0", (errors) => {
				console.log(errors);
        	});
        }
	}
}
</script>

Methods

$auth.
	// Send a (post) request to the loginUrl.
	login(context, input, redirect = false, errorHandler = false)
		
	// Send a (post) request to the signupUrl.
	register(context, input, redirect = false, errorHandler = false login = true)
		
	//Send a (get) request to the logoutUrl.
	logout(context, redirect = false, errorHandler = false)
		
	//Check if a token is being stored and if is not null.
	check()
		
	//Get the token from the localStorage.
	getToken()
		
	//Set a token in the localStorage.
	setToken(token)
		
	//Remove the token from the localStorage.
	removeToken()

License

MIT

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago