mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 15:27:01 +00:00
feature/If a recurring consent already exists for the same PSU (from the same TPP)
This commit is contained in:
parent
ac4c632985
commit
29ec546aa8
@ -1036,6 +1036,25 @@ object Consent extends MdcLoggable {
|
||||
consentsOfBank
|
||||
}
|
||||
|
||||
def expireAllPreviousValidBerlinGroupConsents(consent: MappedConsent): Boolean = {
|
||||
if(consent.status == ConsentStatus.valid.toString &&
|
||||
consent.apiStandard == ApiVersion.berlinGroupV13.apiStandard) {
|
||||
MappedConsent.findAll( // Find all
|
||||
By(MappedConsent.mApiStandard, ApiVersion.berlinGroupV13.apiStandard), // Berlin Group
|
||||
By(MappedConsent.mRecurringIndicator, true), // recurring
|
||||
By(MappedConsent.mStatus, ConsentStatus.valid.toString), // and valid consents
|
||||
By(MappedConsent.mUserId, consent.userId), // for the same PSU
|
||||
By(MappedConsent.mConsumerId, consent.consumerId), // from the same TPP
|
||||
).filterNot(_.consentId == consent.consentId) // Exclude current consent
|
||||
.map(c => // Set to expired
|
||||
c.mStatus(ConsentStatus.expired.toString)
|
||||
.mLastActionDate(new Date()).save
|
||||
).forall(_ == true)
|
||||
} else {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
// Example Usage
|
||||
val box1: Box[String] = Full("Hello, World!")
|
||||
|
||||
@ -2,6 +2,7 @@ package code.api.util
|
||||
|
||||
import java.math.BigInteger
|
||||
import net.liftweb.common.Box
|
||||
import org.iban4j.IbanUtil
|
||||
|
||||
object HashUtil {
|
||||
def Sha256Hash(in: String): String = {
|
||||
@ -25,5 +26,8 @@ object HashUtil {
|
||||
val hashedText = Sha256Hash(plainText)
|
||||
println("Password: " + plainText)
|
||||
println("Hashed password: " + hashedText)
|
||||
println("BBAN: " + IbanUtil.getBban("AT483200000012345864"))
|
||||
println("Bank code: " + IbanUtil.getBankCode("AT483200000012345864"))
|
||||
println("Country code: " + IbanUtil.getCountryCode("AT483200000012345864"))
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,6 +30,7 @@ object MappedConsentProvider extends ConsentProvider {
|
||||
override def updateConsentStatus(consentId: String, status: ConsentStatus): Box[MappedConsent] = {
|
||||
MappedConsent.find(By(MappedConsent.mConsentId, consentId)) match {
|
||||
case Full(consent) =>
|
||||
Consent.expireAllPreviousValidBerlinGroupConsents(consent)
|
||||
tryo(consent
|
||||
.mStatus(status.toString)
|
||||
.mLastActionDate(now) //maybe not right, but for the create we use the `now`, we need to update it later.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user