Set module in nuxt.config.js
modules: [
'@nuxtjs/axios',
['nuxt-auth-jy', { options... }],
],
router: {
middleware: ['authCustom'],
},
or
modules: [
'nuxt-auth-jy' ,
],
authCustom:{
options...
}
router: {
middleware: ['authCustom'],
},
// tsconfig.json
types:[
"nuxt-cart-jy"
]
Yout can set authCustom
mode in page with true
or guest
(default value is false
)
ex:
authCustom: true,
data: () => ({
...
}),
When mode is true
, it only allow logged user to visit.When mode is guest
, it only allow unlogged user to visit.Default value is false
,it means everyone was allowed to visit.
When you use with this package, it will auto inject $authCustom
in your context
- Return:
Promise
- Description:Call
registerUrl
withdata
parameter as payload
- Return:
Promise
- Description:Call
loginUrl
to login withdata
parameter as payload,then auto fetch userdata withuserUrl
.Ifremember
istrue
,the value of key that you set in optionrememberProperty
will be saved fromdata
parameter
- Return:
Promise
- Decription: Login by thirdParty which set in option
oAuth
first then redirect toredirectUrl
- Return:
Boolean
- Description:It will return login status
- Return:
Void
- Description:Logout function
- Return:
Promise
- Description:Fetch userdata with
userUrl
- Return:
Promise
- Description:Edit userdata with
editUrl
- Return:
{token:String,type:String}
- Description:Get current token and type
- Return:
Promise
- Description:If you set
refreshUrl
andrefreshTokenProperty
, you can refresh token by this function
- Return:
Promise
- Description:Reset password with
resetPassUrl
- Type:
String
- Required:
true
- Description: The token property name in
login()
response
- Type:
String
- Required:
true
- Description: Type of token (ex:'bearer')
- Type:
String
- Default:
null
- Description: The refresh token property name in
login()
response
- Type:
String
- Default:
null
- Description: The account property which will be saved in
login()
function first parameter
- Type:
String
- Default:
/
- Description: The path which will redirect when login status is
false
andauthCustom
has been set withtrue
- Type:
String
- Default:
/
- Description: The path which will redirect when login status is
true
andauthCustom
has been set withguest
- Type:
Boolean
- Default:
false
- Description: If you are using
@nuxtjs/i18n
set this option withtrue
- Type:
String
- Default:
authCustom_
- Description: Prefix for cookies
- Type:
Number
- Default:
3600
- Description: Cookie expired time
- Type:
String
- Default:
null
- Description:Register url
- Type:
String
- Default:
null
- Description:Login url
- Type:
String
- Default:
null
- Description:Refresh token url
- Type:
String
- Default:
null
- Description:Fetch userdata url
- Type:
String
- Default:
data
- Description:The property which will been saved as userdata from
fetchUserData()
response
- Type:
String
- Default:
null
- Description:Edit userdata url
- Type:
String
- Default:
null
- Description:Reset password url
- Type:
Array<loginsStrategy>
- Default:
null
- Description:oAuth login config
loginStrategy
:
{
name: required<string>
url: required<string>
}