Join the Webstudio community

Updated 12 hours ago

password protect pages

At a glance

The post is about a community member needing password protection on their pages to hide certain locations from public viewing, as requested by their client. The comments discuss various approaches to this, including hiding the pages from search results, using a password-protected URL path, and creating a pseudo-login dialog. The community members agree that this is not a secure solution, but rather a way to obfuscate the content. One community member provides a detailed implementation of the pseudo-login dialog approach, but notes that it is still not a secure solution and is just a way to protect against those who don't know the password.

Really need to have password protection on pages please. My client has locations that need to be hidden from public viewing as requested by venue provider. Currently using WebFlow so their solution is perfect example for usecase.
1
O
8
A
18 comments
Does your use case require actual safe login? if yes it would be better to have a proper membership login.

Otherwise if its not about truly being secure, but just hidden you could consider:
  1. hiding the page from search results (checkbox in page settings)
  2. naming the page with something people won't guess aka password
password protected page where everyone uses the same password is not a real protection.
Yeah I don't need real protection
Just enough that if people did find it or if I wanted to stop people I could change the password.
Just exactly like webflow's solution is perfect for my use case.
in this case just using an unindexed page with a password as a path should work for you
only inconvenience is that you can't link to that page
something like www.url.com/venue/location-00010/password
is that the suggestion rather than showing a login page before?
yes, but once again its just obfuscation, not a protection, for protection or convenience better to use a proper personal login
I took Oleg's approach one step further and made a pseudo-login dialog.

As Oleg said, it's obfuscation. So I plan to change the password portion of the URL 7 days after I give it to someone, and I've excluded the pages from search engines.

How it works:

  1. User types in password and submits the form
  2. The script does an HTTP request to see if the following page exists: case-studies/[password]/[current-page-slug]
  3. If the request is successful, the password was correct and the user is redirected to that URL
  4. If not, the user is shown an error message to say their password was incorrect
How to implement it:

  1. Create a form with the 'class name' property set to login-form.
  2. Set the form action to #
  3. Add a text input with the 'class name' property set to login-password to the form.
  4. Add a submit button to the form.
  5. Directly after the form, add an HTML embed element. Switch on the "Client Only" property toggle.
  6. Add this code snippet, changing the URL stored in targetPage to match the format of your password-protected pages
Plain Text
<script>
let loginForm = document.getElementById('login-form');
let passwordInput = loginForm.querySelector('#login-password');
const pageSlug = location.pathname.split('/').filter(Boolean).at(-1)

async function tryPassword(password, url) {
  const response = await fetch(url);
  if (!response.ok){
throw new Error("Invalid password");
}
window.location = url

}

loginForm.addEventListener('submit', (event) => {
event.preventDefault()

const inputtedPassword = passwordInput.value

const targetPage = "/case-studies/" + inputtedPassword + "/" +  pageSlug

tryPassword(inputtedPassword, targetPage);

})
 
</script>


This method allows you to have multiple login forms on the same page.

You'll want to code a nicer way of showing the error - I haven't quite gotten round to that yet.
Here's a screen recording of it in action
just for anyone reading - its still not secure at all, just a way to protect against whoever doesn't know the password
@Oleg Isonen It's been a while since this thread was closed. But wanted to bring this up for a similar but different use case.

The use case is I have a design portfolio which would be shared with several people (and can be discovered through social and search). Anyone can access the portfolio. But when being accessed by recruiters, I'd like them to have the option to enter a password and access the case studies (which wouldn't be accessible by anyone who doesn't know the password). It's to ensure only select set of people can access the case studies.

At present it is being done through Webflow - https://shreyansh.design
Would like to avoid a URL that can be easily shared
Got it, sounds like a very similar story to the once we heard before, I agree its needed!
Hopefully it is a near-future roadmap item 🀞

One of the roadblocks when migrating from Webflow to Webstudio
Add a reply
Sign up and join the conversation on Discord
This method allows you to have multiple login forms on the same page.You'll want to code a nicer way of showing the error - I haven't quite gotten round to that yet.","upvoteCount":0,"dateCreated":"2024-03-11T18:49:39.767Z","datePublished":"2024-03-11T18:49:39.767Z","dateModified":"2024-03-11T18:49:39.767Z","url":"https://help.webstudio.is/password-protect-pages-xwzB9m9SL0h3#4fcb4aca-02e4-4812-ae08-45070faa512f","author":{"@type":"Person","url":"https://help.webstudio.is/members/ec997dbc-98e7-430a-a86c-5126c81ea414","name":"AzureDusk10","identifier":"ec997dbc-98e7-430a-a86c-5126c81ea414","image":"https://cdn.discordapp.com/avatars/698482896159244289/f55d71f58c55b4821bae2fcc6064788f.webp?size=256"}},{"@type":"Answer","text":"Here's a screen recording of it in action","upvoteCount":0,"dateCreated":"2024-03-11T19:16:25.588Z","datePublished":"2024-03-11T19:16:25.588Z","dateModified":"2024-03-11T19:16:25.588Z","url":"https://help.webstudio.is/password-protect-pages-xwzB9m9SL0h3#1b58d0a6-fad1-47bf-a1d7-3247b3329820","author":{"@type":"Person","url":"https://help.webstudio.is/members/ec997dbc-98e7-430a-a86c-5126c81ea414","name":"AzureDusk10","identifier":"ec997dbc-98e7-430a-a86c-5126c81ea414","image":"https://cdn.discordapp.com/avatars/698482896159244289/f55d71f58c55b4821bae2fcc6064788f.webp?size=256"}},{"@type":"Answer","text":"clever πŸ™‚","upvoteCount":0,"dateCreated":"2024-03-11T19:20:27.851Z","datePublished":"2024-03-11T19:20:27.851Z","dateModified":"2024-03-11T19:20:27.851Z","url":"https://help.webstudio.is/password-protect-pages-xwzB9m9SL0h3#2e209363-f7ca-43f9-a3ce-2e6b95c15110","author":{"@type":"Person","url":"https://help.webstudio.is/members/cdd3ed87-53a0-414a-885a-56b7939e412a","name":"Oleg Isonen","identifier":"cdd3ed87-53a0-414a-885a-56b7939e412a","image":"https://cdn.discordapp.com/avatars/469405813048606720/8b66a5882214c63ee6148fcce3ef8e93.webp?size=256"}},{"@type":"Answer","text":"just for anyone reading - its still not secure at all, just a way to protect against whoever doesn't know the password","upvoteCount":0,"dateCreated":"2024-03-11T19:20:57.000Z","datePublished":"2024-03-11T19:20:57.000Z","dateModified":"2024-03-11T19:20:57.000Z","url":"https://help.webstudio.is/password-protect-pages-xwzB9m9SL0h3#04b97c9b-32a8-4427-af55-cd5d7ec0d22b","author":{"@type":"Person","url":"https://help.webstudio.is/members/cdd3ed87-53a0-414a-885a-56b7939e412a","name":"Oleg Isonen","identifier":"cdd3ed87-53a0-414a-885a-56b7939e412a","image":"https://cdn.discordapp.com/avatars/469405813048606720/8b66a5882214c63ee6148fcce3ef8e93.webp?size=256"}},{"@type":"Answer","text":"@Oleg Isonen It's been a while since this thread was closed. But wanted to bring this up for a similar but different use case.The use case is I have a design portfolio which would be shared with several people (and can be discovered through social and search). Anyone can access the portfolio. But when being accessed by recruiters, I'd like them to have the option to enter a password and access the case studies (which wouldn't be accessible by anyone who doesn't know the password). It's to ensure only select set of people can access the case studies. At present it is being done through Webflow - https://shreyansh.design","upvoteCount":0,"dateCreated":"2025-01-09T16:34:30.985Z","datePublished":"2025-01-09T16:34:30.985Z","dateModified":"2025-01-09T16:34:31.809Z","url":"https://help.webstudio.is/password-protect-pages-xwzB9m9SL0h3#950a170f-b32d-4f5d-b55f-66f1a072b605","author":{"@type":"Person","url":"https://help.webstudio.is/members/8fbe9955-b00d-48c5-af25-199b7350e8f1","name":"MrShrek","identifier":"8fbe9955-b00d-48c5-af25-199b7350e8f1","image":"https://cdn.discordapp.com/avatars/782739579698020352/513bf02f5122abc1a0f40d02deb9cff3.webp?size=256"}},{"@type":"Answer","text":"Would like to avoid a URL that can be easily shared","upvoteCount":0,"dateCreated":"2025-01-09T16:35:32.880Z","datePublished":"2025-01-09T16:35:32.880Z","dateModified":"2025-01-09T16:35:32.880Z","url":"https://help.webstudio.is/password-protect-pages-xwzB9m9SL0h3#7cc4a65c-5dc4-4132-b2ab-37347f6774ba","author":{"@type":"Person","url":"https://help.webstudio.is/members/8fbe9955-b00d-48c5-af25-199b7350e8f1","name":"MrShrek","identifier":"8fbe9955-b00d-48c5-af25-199b7350e8f1","image":"https://cdn.discordapp.com/avatars/782739579698020352/513bf02f5122abc1a0f40d02deb9cff3.webp?size=256"}},{"@type":"Answer","text":"Got it, sounds like a very similar story to the once we heard before, I agree its needed!","upvoteCount":0,"dateCreated":"2025-01-09T16:38:34.930Z","datePublished":"2025-01-09T16:38:34.930Z","dateModified":"2025-01-09T16:38:34.930Z","url":"https://help.webstudio.is/password-protect-pages-xwzB9m9SL0h3#5d72ed27-ec9c-46a1-8f26-ef878428e7bc","author":{"@type":"Person","url":"https://help.webstudio.is/members/cdd3ed87-53a0-414a-885a-56b7939e412a","name":"Oleg Isonen","identifier":"cdd3ed87-53a0-414a-885a-56b7939e412a","image":"https://cdn.discordapp.com/avatars/469405813048606720/8b66a5882214c63ee6148fcce3ef8e93.webp?size=256"}},{"@type":"Answer","text":"Hopefully it is a near-future roadmap item 🀞 One of the roadblocks when migrating from Webflow to Webstudio","upvoteCount":0,"dateCreated":"2025-01-09T16:50:08.895Z","datePublished":"2025-01-09T16:50:08.895Z","dateModified":"2025-01-09T16:50:08.895Z","url":"https://help.webstudio.is/password-protect-pages-xwzB9m9SL0h3#b27401b8-31d0-46c6-9b7f-f17e38a5e384","author":{"@type":"Person","url":"https://help.webstudio.is/members/8fbe9955-b00d-48c5-af25-199b7350e8f1","name":"MrShrek","identifier":"8fbe9955-b00d-48c5-af25-199b7350e8f1","image":"https://cdn.discordapp.com/avatars/782739579698020352/513bf02f5122abc1a0f40d02deb9cff3.webp?size=256"}}]}}