I need to modify the existing transaction security policy to trigger if user logs in from multiple IP addresses in past 8 hours. I'm using the below SFDC example policy. Can someone give a hand on how to tweak the below code to trigger for 8 hours. Currently the policy is configured to trigger for past 24 hours.
global class LoginPolicyCondition implements TxnSecurity.PolicyCondition {
public boolean evaluate(TxnSecurity.Event e) {
AggregateResult[] results = [SELECT SourceIp
FROM LoginHistory
WHERE UserId = :e.userId
AND LoginTime = LAST_N_DAYS:1
GROUP BY SourceIp];
if(!results.isEmpty() && results.size() > 1) {
return true;
}
return false;
}
}