Skip to content

Commit

Permalink
Merge pull request #669 from digitalfabrik/615-cards-should-have-a-cr…
Browse files Browse the repository at this point in the history
…eator-assigned-in-the-db

615: add creator to card information
  • Loading branch information
sarahsporck authored Dec 14, 2022
2 parents 496a8ae + 0e6342a commit 29471e3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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()
}

Expand All @@ -31,4 +33,5 @@ class CardEntity(id: EntityID<Int>) : IntEntity(id) {
var revoked by Cards.revoked
var cardDetailsHash by Cards.cardDetailsHash
var regionId by Cards.regionId
var issuerId by Cards.issuerId
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions docs/graphql_generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 29471e3

Please sign in to comment.