vue-hamlet

hamlet auth component for frontend

Usage no npm install needed!

<script type="module">
  import vueHamlet from 'https://cdn.skypack.dev/vue-hamlet';
</script>

README

Vue Hamlet

vue-hamlet is used as authentication for frontend.

Index

Install

Install repository into your project.

> npm install yimian/vue-hamlet --save-dev

Configure setting in your project main.js

import Axios from 'axios';
import { sync } from 'vuex-router-sync';
import auth from 'vue-hamlet';
import router from './router';
import store from './store';

Vue.prototype.$http = Axios;
Vue.store = store;
Vue.router = router;

Vue.use(auth, {
  fetchUser: '',
  appKey: '',
});

sync(store, router);

:white_check_mark: TODO

  • mod: change VueResource to axios.
  • add: change password function.
  • add: consts(constants) file.

Demo

Run demo project with following procedures:

cd demo/
npm install
npm run dev

Configuration

Default Configuration:

fetchUser: '/api/auth/me',
appKey: '',
authType: 'Bearer',
hamletPrefix: '/api/auth',
authRedirect: '/login',
refreshInterval: 10, // mins
forbiddenRedirect: '/403',
notFoundRedirect: '/404',

You can rewrite default configuration in your project like:

Vue.use(auth, {
  appKey: '',
});

You can get the common error reason from $auth.consts.