I want to have an authorization prompt pop up every time, but it doesn't pop up every time :/

I have a password prompt for a proxy website, but when I put it in wrong, I do not have the option to re-enter it. How do I make it pop up every time you visit the site? Thanks in advance! The URL is https://vhe.glitch.me :slight_smile:

1 Like

Hmm, it seems to work for me. But FYI Google is planning to disable popups like that one (alert, prompt, and confirm). The best thing to do is create a modal and/or have a login page with private routes to the other pages.

Also, I’d be careful with having something that always pops up like that. In your case there are buttons that will let you close the prompt but you want to make sure you can get to your editor. I once accidentally copied code for a prompt that was in a loop so there was no way to get past it. I had to download the project to get back into my files. :joy:

1 Like

so, it opens up, then if i answer wrong, it says än error message i put if you type in the code right, but it i cannot get the popup again when i reopen it. :man_shrugging:

1 Like

That right there, is a sad moment. :rofl:

1 Like

Heh, I think that’s pretty much a reason for Google wanting to deprecate/disable those. Internet security is also more complex now. They’re not bad for basic Javascript tutorials but they are hacky in real life situations.

I’m not sure how you’ve set up the project you want to privatize but I have a few auth examples using React and/or Redux / Context. Might be more complex than what you need though. I’ve been meaning to make one that’s just Node and vanilla JS. Check out my ‘starters and boilerplates’ collection if you’re curious.

I saw your thread from earlier. If you really want to leave a trail of work: for now, I’d put your project up on Github, with a license, so at least an “initial commit” exists. You can even write in your README when you initially made the project. I’d also keep a copy here if you want to work on it via Glitch, and just push it up to Github periodically. And check out the thread I started about initial commits / remixing if you haven’t.

Hope that’s helpful. I think about this stuff a lot too, considering employers really look at code carefully and I want to get credit for my work.

1 Like

but back to this… how do i fix it? :eye: :lips: :eye:

1 Like

Hmm you don’t want to get stuck in a loop. If you reload the page, the prompt works. You can add a reload button:

<button onclick="location.reload()">reload</button>

EDIT: actually, it doesn’t. :joy: It only works if I clear my cache.

1 Like

how do I make it clear my cache? lol

1 Like

An example of what I want to happen

username is: user
password is: glitch

I want it to act just like this.

1 Like

Heh, you gotta clear your browser cache. In chrome: go to History > Show full history > Clear Browsing Data. I wouldn’t bother doing that though.

I can see your keys, you def want to remove any SSL stuff because people can just take it. Anything private needs to go into the .env file. Seriously: remove those immediately!

1 Like

how do i hide those? can i give you access to my stuff and then you can help me?

1 Like

this is the example. If you see it, try it out.
https://vhe-example.glitch.me/
username: user
password: glitch

1 Like

I really don’t know much about security. Someone else on the forum can probably chime in. This stuff is not easy to set up, and you’re also working on a public platform which might not be the best place to connect proxy servers and the like.

1 Like

well, how can i make the popup act like https://vhe-example.glitch.me on https://vhe.glitch.me?

1 Like

it should maybe act like a normal js popup.

1 Like

You’ve got a lot of code there and it would take me a while to go through it. I’d try removing or changing the cache options though. Specifically lines 61 and 62 in the vhe file. That might be blocking the reload. Remember you can comment out code rather than just deleting so you don’t forget anything.

The vhe-example is much shorter; I’d make sure you’re copying that exactly while making sure you account for any extras regarding your own project. Take your time with it; it looks like everything you need is there.

1 Like

i greyed out line 61 and 62, still didn’t work. ill give you pemissions so you can try looking at it.

1 Like

I don’t have time to look at it right now. Feel free to follow the help I’ve given you so far.

:+1: thanks :slight_smile:

1 Like

BTW, I did get a chance to quickly look at your files and I moved the keys and cert into .env. Make sure you reference those with process.env.cert, process.env.key, etc.

I tried replacing the res.end(‘bad creds’) with a res.redirect or res.json({ msg: "bad creds! }) but nothing worked. There’s other code in there that is probably forcing that outcome. Whereas the example project is using req, res, next to help create a refresh or loop of the prompt. Someone more experienced with Node and/or security would have more insight here.