stephenkr / nuxt-password-protect

The Nuxt password protect module
MIT License
37 stars 9 forks source link

feature request: enable multiple passwords for different routes #46

Open phivk opened 3 years ago

phivk commented 3 years ago

I have use case where I need multiple routes protected with different passwords.

I could imagine something like this in nuxt.config.js:

module.exports = {
  modules: ['nuxt-password-protect'],

  passwordProtect: {
    enabled: true,
    formPath: '/password',
    passwords: ['hello-world', 'another-pw-here'],
    enabledPaths: [
        ['/page-protected-with-first-pw', '/another-page-protected-with-first-pw'],
        ['/page-protected-with-second-pw', '/another-page-protected-with-second-pw']
    ],
    tokenSeed: 101010,
    queryString: '_pw',
    cookieName: '_password',
    cookie: {
      prefix: '',
      expires: 5
    },
    ignoredPaths: ['/public-page']
  }
}
kalnode commented 2 years ago

Getting into multiple passwords and multiple routes seems like growing scope of this simple module...

Anyhow, there's many ways to peel-an-orange, and I would think some parent-child relationship is clearer than matching array index between separate variables.

passwords: [
    'myPass1': [
         '/path44ee',
         '/path55rr',
         '/path22gg'
    ],
    'myPass2': [
         '/path88kkkkk',
         '/path33eeeee',
         '/path55555'
    ]
]
stephenkr commented 2 years ago

Hi @phivk sorry i havent replied sooner.

I think this is out of scope from the original intention of this module. It is only meant to protect a single part of the website.

Thank you for suggesting the idea though. Also i am not maintaining this module as much as before, please feel free to fork and extend it.

phivk commented 2 years ago

No worries @stephenkr, I have actually done a rearchitecture of my project, which means I no longer have the use case for this feature anymore... Feel free to close the issue if you like.