我的 asp.net 应用程序使用自定义逻辑来实现用户登录功能。要求之一是用户(一旦锁定)必须在 15 分钟后才能获得访问权限。
我目前的逻辑是:
// check if account is locked & LastLoginAttempt is NOT over 15 minutes;
if ((iLoginAttempts > 4) && ( dtCurrentTimePlus15 < dtLastLoginAttempt))
{
oCust.CustLoginStatus = "Your account is currently locked.";
return false;
}
但是,当 iLoginAttempts = 5 且 dtLastLoginAttempt 是 2 分钟前时......为什么上面的逻辑会跳过 if 子句?
最佳答案
因为
dtCurrentTimePlus15 = 15
和
dtLastLoginAttempt = 2
将语句反转为:
if ((iLoginAttempts > 4) && (dtLastLoginAttempt < dtCurrentTimePlus15))
{
oCust.CustLoginStatus = "Your account is currently locked.";
return false;
}
关于c# - 设置用户登录尝试时出现逻辑错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11723770/