gpt4 book ai didi

c# - 设置用户登录尝试时出现逻辑错误

转载 作者:太空宇宙 更新时间:2023-11-03 11:18:48 25 4
gpt4 key购买 nike

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com