我正在尝试制作一个nocatsplash页面 - 它使用HTML代码来检查密码并在输入正确的密码时重定向访问者
I am trying to make a nocatsplash page- it uses HTML code to check a password and redirect visitors if a correct password is entered
我目前有一个工作代码,允许用户在单击按钮接受条款后通过。我想集成一个密码字段和接受按钮,只有在密码正确的情况下才允许某人通过。
这是我当前带有简单按钮的工作代码:
Agree to Connect:
<br>
<br>
<form method="post" id="login" action="http://10.0.0.1:5280/">
<input type="hidden" name="accept_terms" value="yes">
<input type="hidden" name="redirect" value="http://www.anderson1216.com/wifi-success.html">
<input type="hidden" name="mode_login">
<input type="submit" value="Accept Terms of Use and Connect">
</form>
<br>
//agreement text here
<br>
<br>
We thank you for your understanding and cooperation.
<br>
<br>
<form method="post" id="login" action="http://10.0.0.1:5280/">
<input type="hidden" name="accept_terms" value="yes">
<input type="hidden" name="redirect" value="http://www.anderson1216.com/wifi-success.html">
<input type="hidden" name="mode_login">
<input type="submit" value="Accept Terms of Use and Connect">
</form>
这是我找到的一个简单的密码表单:
<head>
<script type="text/javascript">
function isValid(){
var password = document.getElementById('password').value;
if (password == "password123")
{alert('Correct!')
else
{alert('Wrong Password')}
}
</script>
</head>
<form name="PasswordField" action="">
Password:
<input type="password" id="password" name="password">
<input type="button" value="Log in" onclick="isValid();">
</form>
为了使代码正常工作,需要将第一个代码块中的第一个语句包含在某处,以告诉路由器该人接受了,然后我希望它在他们单击按钮后重定向到另一个网站。正确的密码不需要警报,只需要不正确的密码。有什么建议吗?
我会认真地建议不要在js中列出密码!!任何查看源代码的人都可以看到这一点。您需要实现一个更安全的密码系统,其中包含保存在安全数据库中的散列和加盐密码,并通过 AJAX 调用或 PHP 进行检查。
看起来您想将其放在家用路由器上,可能作为登录页面? 如果你能详细说明一点,我也许能够提供更多的帮助。
如果您试图阻止某人访问该网站,除非他们知道秘密密码,那么这不是解决问题的方法。 您可能希望在服务器端而不是客户端对用户进行身份验证,因为任何对 JavaScript 了解有限的人都可以使用开发人员控制台在客户端进行欺骗身份验证。
但是,如果您只是想通过输入任意已知密码来确保人类同意协议条款,那么此方法就可以了。
为了安全起见,我同意上面的 gavrig 对它们进行哈希和加盐。
但是,如果我答对了你的问题,这是我整理的小提琴来解决它。我故意混合了jquery和javascript。
Agree to Connect:
<br>
<br>
//agreement text here
<br>
<br>
We thank you for your understanding and cooperation.
<br>
<br>
<form method="post" id="login" action="http://10.0.0.1:5280/">
<input type="password" id="password" name="password">
<input type="hidden" name="accept_terms" value="yes">
<input type="hidden" name="redirect" value="http://www.anderson1216.com/wifi-success.html">
<input type="hidden" name="mode_login">
<input type="submit" value="Accept Terms of Use and Connect">
</form>
$('form').on('submit', function(e){
e.preventDefault();
var password = document.getElementById('password').value;
if (password == "password123")
{
this.submit();
}
else
{
alert('Wrong Password');
}
});
https://jsfiddle.net/tL7qcc5n/2/
NoCatSplash 不支持身份验证。任何用户都可以通过手动发布到 http://10.0.0.1:5280/来绕过您的身份验证
如果您认真对待身份验证,则应使用其他方法,例如使用 Radius 服务器。这甚至可以安装在路由器本身上,因为它有足够好的硬件来支持它。
- 如何在ajax中检查密码是否小于8个字符
- 如何为在客户端检查其密码的用户创建登录页面
- 如何使用Passport.js本地策略检查当前密码并(如果正确)更新密码
- 检查密码匹配时出错
- 检查密码-代码中的错误在哪里
- 正在创建用于密码检查的UML类图
- 创建 1337 密码检查器(javascript)
- 角度 js ng-keyup 不适用于密码强度检查
- 根据字符串数组检查字符串(密码验证)
- 检查密码是否匹配
- 我正在尝试制作一个nocatsplash页面 - 它使用HTML代码来检查密码并在输入正确的密码时重定向访问者
- 密码检查器未按预期工作
- 页面加载前的密码检查
- 密码检查器纯js.如何根据密码检查器中的规则进行检查
- 修改正则表达式密码检查器
- 使用nodejs进行错误邮件/密码检查的推送通知
- Javascript密码检查与确认不工作
- 特殊字符的密码检查
- JavaScript密码检查和打开.html文件,如果正确
- angularjs中的密码检查指令