Pop Up Password Protect
Solution 1:
When you say ASP I assume you mean pre .NET. If so then I think a small change to the VB/HTML in the page would be better. Of course this is only an example and not a very secure one at that - but still it is a little better than a plain JS solution.
Example - thenameofthepage.asp
<%
needAuthentication = True
If Request.Form.Count > 0 Then
If Request.Form("username") <> "jon" Or Request.Form("password") <> "secret" Then
' Redirect to another URI
Response.Redirect("/")
Response.End
End If
needAuthentication = False
End If
%>
<html><body>
<%
If needAuthentication Then
%>
<formmethod="post"action="thenameofthepage.asp"><div>Username: <inputtype="text"name="username" /></div><div>Password: <inputtype="text"name="password" /></div><div><inputtype="submit"value="Submit" /></div></form>
<%
Else
%>
<p>Page content here</p>
<%
End If
%>
</body></html>
Solution 2:
It is possible to create a modal dialog box using Javascript. There are reasonable tutorials on doing so here and link text and a list of pre-existing libraries that cover modal dialogs here.
Using something like this for authentication is a violation of all that is holy. Please point out to whoever is requiring this how trivial it is to subvert this scheme.
Solution 3:
Very very wrong indeed, but this should do:
var passwords = newObject;
passwords['some user'] = 'some password';
functioncheck_password(tries){
var username = prompt('Please enter your username');
var password = prompt('Please enter your password');
if(passwords[username] != password){
if(tries == 3){
window.location = 'http://www.google.com/';
}else{
check_password(tries + 1);
}
}
}
check_password(1);
To make sure someone can't get the password right away you could use some hashing algorithm. And if you put display:none
on all important elements you could make it only show the contents when "logged in"
Solution 4:
Of course this is a dumb idea.
But have you thought about adding an extra thin layer of security.. i.e. instead of popping up the JavaScript modal (or in addition to), can you redirect to the password + '.asp'?
Example, the next page is called something.asp
. So you can make the password something
and then do a
window.location = userInput + '.asp';
It is slightly more obfuscated.
Post a Comment for "Pop Up Password Protect"