feat(desktop-onboarding): neue Onboarding-UI implementiert, Backup- und Rollenmanagement hinzugefügt
Desktop CI — Headless Tests & Build / Compose Desktop — Tests (headless) & Build (push) Failing after 3m10s
Build and Publish Docker Images / build-and-push (., backend/infrastructure/gateway/Dockerfile, api-gateway, api-gateway) (push) Successful in 6m37s
Build and Publish Docker Images / build-and-push (., backend/services/ping/Dockerfile, ping-service, ping-service) (push) Successful in 5m59s
Build and Publish Docker Images / build-and-push (., config/docker/keycloak/Dockerfile, keycloak, keycloak) (push) Has been cancelled
Build and Publish Docker Images / build-and-push (., config/docker/caddy/web-app/Dockerfile, web-app, web-app) (push) Has been cancelled
Desktop CI — Headless Tests & Build / Compose Desktop — Tests (headless) & Build (push) Failing after 3m10s
Build and Publish Docker Images / build-and-push (., backend/infrastructure/gateway/Dockerfile, api-gateway, api-gateway) (push) Successful in 6m37s
Build and Publish Docker Images / build-and-push (., backend/services/ping/Dockerfile, ping-service, ping-service) (push) Successful in 5m59s
Build and Publish Docker Images / build-and-push (., config/docker/keycloak/Dockerfile, keycloak, keycloak) (push) Has been cancelled
Build and Publish Docker Images / build-and-push (., config/docker/caddy/web-app/Dockerfile, web-app, web-app) (push) Has been cancelled
- Einbindung eines komplett überarbeiteten Onboarding-Screens mit validierten Eingaben für Gerätename, Sicherheitsschlüssel und Backup-Pfad. - `SettingsManager` eingeführt zur Speicherung der Onboarding-Daten in `settings.json`. - Navigation verbessert: Onboarding-Workflow startet, wenn Konfiguration fehlt; neues "Setup"-Icon in der Navigationsleiste hinzugefügt. - Backend: Geräte-API und `DeviceSecurityFilter` für Authentifizierung per Sicherheitsschlüssel implementiert. Signed-off-by: Stefan Mogeritsch <stefan.mo.co@gmail.com>
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
package at.mocode.identity.infrastructure.persistence
|
||||
|
||||
import at.mocode.identity.domain.model.DeviceRole
|
||||
import org.jetbrains.exposed.v1.core.Table
|
||||
import org.jetbrains.exposed.v1.core.java.javaUUID
|
||||
import org.jetbrains.exposed.v1.datetime.timestamp
|
||||
|
||||
/**
|
||||
* Exposed Table definition für registrierte Desktop-Geräte.
|
||||
*/
|
||||
object DeviceTable : Table("identity_devices") {
|
||||
val id = javaUUID("id").autoGenerate()
|
||||
override val primaryKey = PrimaryKey(id)
|
||||
|
||||
val name = varchar("name", 100).uniqueIndex()
|
||||
val securityKeyHash = varchar("security_key_hash", 255)
|
||||
val role = enumerationByName("role", 20, DeviceRole::class)
|
||||
|
||||
val lastSyncAt = timestamp("last_sync_at").nullable()
|
||||
val createdAt = timestamp("created_at")
|
||||
val updatedAt = timestamp("updated_at")
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
package at.mocode.identity.infrastructure.persistence
|
||||
|
||||
import at.mocode.identity.domain.model.Device
|
||||
import at.mocode.identity.domain.repository.DeviceRepository
|
||||
import org.jetbrains.exposed.v1.core.ResultRow
|
||||
import org.jetbrains.exposed.v1.core.eq
|
||||
import org.jetbrains.exposed.v1.jdbc.insert
|
||||
import org.jetbrains.exposed.v1.jdbc.selectAll
|
||||
import org.jetbrains.exposed.v1.jdbc.transactions.transaction
|
||||
import org.jetbrains.exposed.v1.jdbc.update
|
||||
import java.util.*
|
||||
import kotlin.time.Clock
|
||||
import kotlin.time.Instant
|
||||
import kotlin.time.toJavaInstant
|
||||
|
||||
class ExposedDeviceRepository : DeviceRepository {
|
||||
|
||||
override suspend fun findById(id: UUID): Device? = transaction {
|
||||
DeviceTable.selectAll().where { DeviceTable.id eq id }
|
||||
.map { rowToDevice(it) }
|
||||
.singleOrNull()
|
||||
}
|
||||
|
||||
override suspend fun findByName(name: String): Device? = transaction {
|
||||
DeviceTable.selectAll().where { DeviceTable.name eq name }
|
||||
.map { rowToDevice(it) }
|
||||
.singleOrNull()
|
||||
}
|
||||
|
||||
override suspend fun save(device: Device): Device = transaction {
|
||||
val now = Clock.System.now()
|
||||
val existing = DeviceTable.selectAll().where { DeviceTable.id eq device.id }.singleOrNull()
|
||||
|
||||
if (existing != null) {
|
||||
DeviceTable.update({ DeviceTable.id eq device.id }) {
|
||||
it[name] = device.name
|
||||
it[securityKeyHash] = device.securityKeyHash
|
||||
it[role] = device.role
|
||||
it[lastSyncAt] = device.lastSyncAt?.toJavaInstant()
|
||||
it[updatedAt] = now.toJavaInstant()
|
||||
}
|
||||
} else {
|
||||
DeviceTable.insert {
|
||||
it[id] = device.id
|
||||
it[name] = device.name
|
||||
it[securityKeyHash] = device.securityKeyHash
|
||||
it[role] = device.role
|
||||
it[lastSyncAt] = device.lastSyncAt?.toJavaInstant()
|
||||
it[createdAt] = now.toJavaInstant()
|
||||
it[updatedAt] = now.toJavaInstant()
|
||||
}
|
||||
}
|
||||
device
|
||||
}
|
||||
|
||||
override suspend fun updateLastSyncAt(id: UUID, at: Instant): Boolean = transaction {
|
||||
val javaInstant = at.toJavaInstant()
|
||||
DeviceTable.update({ DeviceTable.id eq id }) {
|
||||
it[lastSyncAt] = javaInstant
|
||||
it[updatedAt] = javaInstant
|
||||
} > 0
|
||||
}
|
||||
|
||||
private fun rowToDevice(row: ResultRow): Device = Device(
|
||||
id = row[DeviceTable.id],
|
||||
name = row[DeviceTable.name],
|
||||
securityKeyHash = row[DeviceTable.securityKeyHash],
|
||||
role = row[DeviceTable.role],
|
||||
lastSyncAt = row[DeviceTable.lastSyncAt]?.let { Instant.fromEpochMilliseconds(it.toEpochMilli()) },
|
||||
createdAt = Instant.fromEpochMilliseconds(row[DeviceTable.createdAt].toEpochMilli())
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user