使用Meteor, Meteor.loginWithPassword 函数调用服务器,然后当用户不存在时返回User not found
错误,或者当密码执行时返回Match failed
与用户的密码不符。
服务器是否有一种简单的方法可以在登录失败的两个条件下返回相同错误(或没有错误)?
我不希望黑客知道他们何时在我的系统上找到了有效的用户名或用户ID。我不希望服务器说出User not found
,告诉潜在的黑客何时(或没有)找到有效用户。如果能够轻松地更改服务器从 accounts-password Meteor模块返回的错误消息,以便稍微加强安全性,那将会很棒。我不希望服务器的错误结果是通用的,如failed
或未定义或null,无论登录错误的原因是什么。
我知道我可以分叉/重新使用帐户密码模块,但希望有更简单的东西。
谢谢!
答案 0 :(得分:1)
是的,您可以将函数放在/ server-folder中的某个位置并更改错误消息。像这样:
Accounts.validateLoginAttempt(function(options) {
if (!options.allowed) { //that is, if there's an error
throw new Meteor.Error('login-error', 'Error!');
}
//...other code for other purposes below
});
/server/accounts.js