mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 17:17:09 +00:00
feature/96 - TPP requests without PSU involvement
This commit is contained in:
parent
2719d0e469
commit
f3133ebb4a
@ -532,25 +532,30 @@ object Consent extends MdcLoggable {
|
||||
}
|
||||
|
||||
def checkFrequencyPerDay(storedConsent: consent.ConsentTrait) = {
|
||||
def isSameDay(date1: Date, date2: Date): Boolean = {
|
||||
val fmt = new SimpleDateFormat("yyyyMMdd")
|
||||
fmt.format(date1).equals(fmt.format(date2))
|
||||
}
|
||||
var usesSoFarTodayCounter = storedConsent.usesSoFarTodayCounter
|
||||
storedConsent.recurringIndicator match {
|
||||
case false => // The consent is for one access to the account data
|
||||
if(usesSoFarTodayCounter == 0) // Maximum value is "1".
|
||||
(true, 0) // All good
|
||||
else
|
||||
(false, 1) // Exceeded rate limit
|
||||
case true => // The consent is for recurring access to the account data
|
||||
if(!isSameDay(storedConsent.usesSoFarTodayCounterUpdatedAt, new Date())) {
|
||||
usesSoFarTodayCounter = 0 // Reset counter
|
||||
}
|
||||
if(usesSoFarTodayCounter < storedConsent.frequencyPerDay)
|
||||
(true, usesSoFarTodayCounter) // All good
|
||||
else
|
||||
(false, storedConsent.frequencyPerDay) // Exceeded rate limit
|
||||
if(BerlinGroupCheck.isTppRequestsWithoutPsuInvolvement(callContext.requestHeaders)) {
|
||||
def isSameDay(date1: Date, date2: Date): Boolean = {
|
||||
val fmt = new SimpleDateFormat("yyyyMMdd")
|
||||
fmt.format(date1).equals(fmt.format(date2))
|
||||
}
|
||||
|
||||
var usesSoFarTodayCounter = storedConsent.usesSoFarTodayCounter
|
||||
storedConsent.recurringIndicator match {
|
||||
case false => // The consent is for one access to the account data
|
||||
if (usesSoFarTodayCounter == 0) // Maximum value is "1".
|
||||
(true, 0) // All good
|
||||
else
|
||||
(false, 1) // Exceeded rate limit
|
||||
case true => // The consent is for recurring access to the account data
|
||||
if (!isSameDay(storedConsent.usesSoFarTodayCounterUpdatedAt, new Date())) {
|
||||
usesSoFarTodayCounter = 0 // Reset counter
|
||||
}
|
||||
if (usesSoFarTodayCounter < storedConsent.frequencyPerDay)
|
||||
(true, usesSoFarTodayCounter) // All good
|
||||
else
|
||||
(false, storedConsent.frequencyPerDay) // Exceeded rate limit
|
||||
}
|
||||
} else {
|
||||
(true, 0) // All good
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user