diff --git a/backend/src/main/kotlin/app/ehrenamtskarte/backend/verification/database/Schema.kt b/backend/src/main/kotlin/app/ehrenamtskarte/backend/verification/database/Schema.kt index fdb13c0b6..6af12e565 100644 --- a/backend/src/main/kotlin/app/ehrenamtskarte/backend/verification/database/Schema.kt +++ b/backend/src/main/kotlin/app/ehrenamtskarte/backend/verification/database/Schema.kt @@ -1,5 +1,6 @@ package app.ehrenamtskarte.backend.verification.database +import app.ehrenamtskarte.backend.auth.database.Administrators import app.ehrenamtskarte.backend.regions.database.Regions import org.jetbrains.exposed.dao.IntEntity import org.jetbrains.exposed.dao.IntEntityClass @@ -19,6 +20,7 @@ object Cards : IntIdTable() { val issueDate = timestamp("issueDate").defaultExpression(CurrentTimestamp()) val revoked = bool("revoked") val regionId = reference("regionId", Regions) + val issuerId = reference("issuerId", Administrators) val cardDetailsHash = binary("cardDetailsHash", CARD_DETAILS_HASH_LENGTH).uniqueIndex() } @@ -31,4 +33,5 @@ class CardEntity(id: EntityID) : IntEntity(id) { var revoked by Cards.revoked var cardDetailsHash by Cards.cardDetailsHash var regionId by Cards.regionId + var issuerId by Cards.issuerId } diff --git a/backend/src/main/kotlin/app/ehrenamtskarte/backend/verification/database/repos/CardRepository.kt b/backend/src/main/kotlin/app/ehrenamtskarte/backend/verification/database/repos/CardRepository.kt index a5cb68e23..144d67f82 100644 --- a/backend/src/main/kotlin/app/ehrenamtskarte/backend/verification/database/repos/CardRepository.kt +++ b/backend/src/main/kotlin/app/ehrenamtskarte/backend/verification/database/repos/CardRepository.kt @@ -1,5 +1,6 @@ package app.ehrenamtskarte.backend.verification.database.repos +import app.ehrenamtskarte.backend.auth.database.Administrators import app.ehrenamtskarte.backend.projects.database.Projects import app.ehrenamtskarte.backend.regions.database.Regions import app.ehrenamtskarte.backend.verification.database.CardEntity @@ -19,13 +20,14 @@ object CardRepository { return if (query == null) null else CardEntity.wrapRow(query) } - fun insert(cardDetailsHash: ByteArray, totpSecret: ByteArray, expirationDay: Long?, regionId: Int) = + fun insert(cardDetailsHash: ByteArray, totpSecret: ByteArray, expirationDay: Long?, regionId: Int, issuerId: Int) = CardEntity.new { this.cardDetailsHash = cardDetailsHash this.totpSecret = totpSecret this.expirationDay = expirationDay this.issueDate = Instant.now() this.regionId = EntityID(regionId, Regions) + this.issuerId = EntityID(issuerId, Administrators) this.revoked = false } } diff --git a/backend/src/main/kotlin/app/ehrenamtskarte/backend/verification/webservice/schema/CardMutationService.kt b/backend/src/main/kotlin/app/ehrenamtskarte/backend/verification/webservice/schema/CardMutationService.kt index 116980ddd..5e8659115 100644 --- a/backend/src/main/kotlin/app/ehrenamtskarte/backend/verification/webservice/schema/CardMutationService.kt +++ b/backend/src/main/kotlin/app/ehrenamtskarte/backend/verification/webservice/schema/CardMutationService.kt @@ -23,12 +23,12 @@ class CardMutationService { if (!Authorizer.mayCreateCardInRegion(user, targetedRegionId)) { throw UnauthorizedException() } - CardRepository.insert( Base64.decode(card.cardDetailsHashBase64), Base64.decode(card.totpSecretBase64), card.cardExpirationDay, - card.regionId + card.regionId, + user.id.value ) } return true diff --git a/docs/graphql_generation.md b/docs/graphql_generation.md index cf720b0ce..298159eda 100644 --- a/docs/graphql_generation.md +++ b/docs/graphql_generation.md @@ -6,6 +6,5 @@ Queries are specified in [frontend/graphql_queries](../frontend/graphql_queries) ## Generate API Files 1. If schema changed: Generate updated GraphQL schema into [schema.graphql](../frontend/schema.graphql) Run "Generate GraphQL" in Intellij (or `./gradlew run --args="graphql-export ../specs/backend-api.graphql"` in the backend folder) -2. Run "Generate GraphQL Flutter Client" (or first copy `backend/schema.graphql` to `frontend/schema.graphql` and - run ```flutter pub run build_runner build``` in the `frontend` directory +2. Run any "Select" configuration in IntelliJ e.g. "Select bayern" (or `flutter pub run build_runner build` in the `frontend` directory) 3. Run "Generate GraphQL React Client" (or `npm generate-graphql` in the `administration` directory)