wa-auth
v0.2.6
Published
What does this package do? 1. check is Login 2. set user and check Auth in `Vue.prototype.$auth.user` and `Vue.prototype.$auth.check` - use in Component => `$auth` or `this.$auth` 3. set Token in Header Axios 4. write api Login, Register, Logout, Forg
Downloads
13
Readme
Package wa-auth
What does this package do?
- check is Login
- set user and check Auth in
Vue.prototype.$auth.user
andVue.prototype.$auth.check
- use in Component =>
$auth
orthis.$auth
- use in Component =>
- set Token in Header Axios
- write api Login, Register, Logout, Forgot Password
Prerequisites
- [x] use package we-axios. OR
- [x] set axios in Vue.prototype.$axios
##install
npm install wa-auth
##Usage
use in main:
import Auth from 'wa-auth'
Vue.use(Auth, options);
defult Options:
const options = {
api: {
login: 'v1/login',
logout: 'v1/logout',
register: 'v1/register',
verify_register: 'v1/verify-register',
forgot_pass: 'v1/forgot-password',
verify_forgot_pass: 'v1/verify-forgot-password',
reset_pass: 'v1/reset-password',
}
};
###Check Login OR Get User
import Auth from 'wa-auth'
// check Login
Auth.isLogin
//Get User
Auth.getUser
OR
use $auth.check
and $auth.user
in Component
###Login:
import {login} from 'wa-auth'
login(requestData, redirect);
redirect
is string
requestData
is object
if redirect == null
Then Not Redirect
###Logout:
import {logout} from 'wa-auth'
logout(redirect);
OR use in components:
$_logout(redirect);
redirect
is string
if redirect == null
Then Not Redirect
###Register:
import {register} from 'wa-auth'
register(requestData);
requestData
is object
import {verify_register} from 'wa-auth'
verify_register(requestData, redirect);
redirect
is string
requestData
is object
if redirect == null
Then Not Redirect
###Forgot Password:
import {forgot_pass} from 'wa-auth'
forgot_pass(requestData);
requestData
is object
import {verify_forgot_pass} from 'wa-auth'
verify_forgot_pass(requestData);
requestData
is object
###Reset Password:
import {reset_pass} from 'wa-auth'
reset_pass(requestData, redirect);
redirect
is string
requestData
is object
if redirect == null
Then Not Redirect
##$emit: has $emit login and logout use:
Vue._instance.$on('login', function () {
//code
});
Vue._instance.$on('logout', function () {
//code
});