0

我目前有一个工作代码,只允许用户单击按钮接受条款后通过。我想集成一个密码字段和接受按钮,只有在密码正确的情况下才允许某人通过。

这是我当前使用简单按钮的工作代码:

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>

为了使代码正常工作,第一块代码中的第一条语句需要包含在某处以告诉路由器该人接受,然后我希望它在他们单击按钮后重定向到另一个网站。正确的密码不需要警报,只需要不正确的密码。有什么建议么?

4

4 回答 4

0

看起来你想把它放在家用路由器上,可能作为登陆页面?如果您能详细说明一下,我可能会提供更多帮助。

如果您试图阻止某人访问该站点,除非他们知道秘密密码,那么这不是解决问题的方法。您可能希望在服务器端而不是客户端对用户进行身份验证,因为任何对 JavaScript 了解有限的人都​​可以使用开发人员控制台在客户端欺骗身份验证。

但是,如果您只是想通过输入任意已知密码来确定某人是否同意协议条款,那么这种方法很好。

于 2016-02-12T04:53:02.187 回答
0

我强烈建议不要在 js 中列出密码!任何查看源代码的人都可以看到这一点。您需要实现一个更安全的密码系统,将散列和加盐密码保存在安全数据库中,并通过 AJAX 调用或 PHP 进行检查。

于 2016-02-12T04:42:39.180 回答
0

为了安全起见,我同意上面的 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/

于 2016-02-12T05:05:54.323 回答
0

NoCatSplash 不支持身份验证。任何用户都可以通过手动发布到http://10.0.0.1:5280/来绕过您的身份验证

如果您认真对待身份验证,则应使用另一种方法,例如使用 Radius 服务器。这甚至可以安装在路由器本身上,因为它有足够好的硬件来支持它。

于 2021-05-03T11:46:42.357 回答