我的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/