Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

615: add creator to card information #669

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)