- Add
nuxt-website-lock
dependency to your project
yarn add nuxt-website-lock # or npm install nuxt-website-lock
- Add
nuxt-website-lock
to themodules
section ofnuxt.config.js
{
modules: [
// Simple usage
'nuxt-website-lock',
// website-lock has to be before axios so axios instance is available at websitelock module
// to enable validation of token on BE change "enableServerValidation" to true
['nuxt-website-lock', { enableServerValidation: false, enabled: true, password: 'superSecretPassword' }],
'@nuxtjs/axios',
]
}
After setting up the options
properly, all you need to do is apply the WebsiteLock
route middleware to the page(s),
which should be locked
Option name | Description | Default value | Possible values |
---|---|---|---|
enabled |
whether website lock should be enabled | default: null |
options: true /false |
password |
password which unlocks website | default: null |
any string (will be simply hashed to md5) |
formPath |
url at which the form for website lock will be | default: /website-lock |
any string starting with slash |
enableServerValidation |
whether password should be validated against BE (tailor fitted for personal use, will be expanded upon in later versions) | default: false |
options: true /false |
cookieName |
name of the cookie under which the hashed token will be stored | default: websiteLock._token |
any string, cannot be null |
cookie |
object storing some cookie | ||
cookie.prefix |
prefix of cookieName being stored |
default: '' |
any string, cannot be null |
cookie.expires |
number of days in which the cookie will expire | default: 2 |
any unsigned integer |
- better customizability
- Clone this repository
- Install dependencies using
yarn install
ornpm install
- Start development server using
npm run dev
Copyright (c) Patrik Jánosdeák