Click to See Complete Forum and Search --> : Password Protection


p40s4me
01-20-2003, 08:48 AM
GOOD MORNING ALL,
JUST WONDERING IF ANYBODY HAS ANY GOOD IDEAS ON PASSWORD PROTECTING A PAGE USING JAVASCRIPT. I WOULD LIKE TO AVOID USING AN APPLICATION (I.E jsp, or asp) I HAVE FOUND ONE WAY WITH JAVASCRIPT EXCEPT IF SOMEBODY VIEWS THE SOURCE ALL OF THE PASSWORDS FOR USERNAMES ARE VISIBLE. I WOULD NEED TO BE ABLE TO HIDE THE SOURCE CODE COMPLETELY, AND ALSO I NEED TO BLOCK ANYONE FROM ACCESSING THE PROTECTED PAGE BY ENTERING THE URL DIRECTLY. CAN I FORCE THEM TO COME IN FROM THE LOGIN PAGE? ANY HELP WOULD BE APPRECIATED. THANK YOU.

Nicodemas
01-20-2003, 09:16 AM
There is no absolutel way to secure usernames/passwords using only Javascript. You can use one of those snazzy little encrypters, but those aren't full proof against veterans that know what their looking at. Sorry :(

p40s4me
01-20-2003, 09:38 AM
THE PAGE I'M MAKING DOES NOT NEED TO BE VERY SECURE. I JUST WANT PEOPLE TO HAVE TO LOG IN TO VIEW IT & I WANT TO MAKE SURE NOBODY CAN JUST ENTER THE URL FOR THE PAGE DIRECTLY TO ACCESS IT.

mawood
01-20-2003, 11:43 AM
You can do something like this, though:

On page 1 (password.html)


<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function pass() {
var pass = ''
pass=prompt('Enter your password:','');
if (password != null) {
location.href= pass + ".html";
}
}
// End -->
</SCRIPT>

Say the password is booyaa, it would send you to booyaa.html. THEN... on the second page add:

<SCRIPT LANGUAGE="JavaScript"><!--
booyaafrom = document.referrer;
if (booyaafrom != htpp://www.xxxxxx.com/password.html) {
location.href = 'sorryaboutyerluck.html';
}
//--></SCRIPT>

..it will send them to sorryaboutyerluck.html if they do not come from the password page. This can be stopped if they turn off javascript in their browser, but under normal circumstanses, they won't be able to just type in the url of the page you want to do this to.

pyro
01-20-2003, 11:48 AM
If you really don't care about security, you could pick up a script here. http://javascript.internet.com/passwords/ But, as has been stated, there is no such thing as a secure javascript password.