Compare commits

..

5 commits

Author SHA1 Message Date
oskar 400319e502 Implement invite management on mobile
All checks were successful
ci / changes (push) Successful in 3s
ci / backend (push) Has been skipped
ci / flutter (push) Successful in 1m8s
- Added Flutter invite screens for accepting/resolving invitations and handling invalid states with `InviteScreen` and `InvalidInviteScreen`.
- Integrated `InviteController` with accompanying `InviteApi` for resolving and accepting invites.
- Updated routing logic to handle `/invite` and `/invite/invalid` paths.
- Added localization strings for invite-related messages.
- Enabled Flutter deep link handling across all supported platforms.
- Implemented unit tests for `InviteController` and `InviteLinkService`.
- Updated project entitlements and configurations for invite link validation on iOS/Android.
- Enhanced dependency injection with invite modules and services.
2026-01-16 22:13:51 +01:00
oskar df17dc3f2e Remove redundant workflow filters for .forgejo/workflows/**.
All checks were successful
ci / changes (push) Successful in 3s
ci / backend (push) Has been skipped
ci / flutter (push) Has been skipped
2026-01-16 22:11:39 +01:00
oskar 6d3b1cbffd Set fetch-depth: 0 in Forgejo Actions CI workflows to fetch full history
Some checks failed
ci / changes (push) Successful in 4s
ci / backend (push) Successful in 1m46s
ci / flutter (push) Has been cancelled
2026-01-16 22:09:28 +01:00
oskar dc4bc979af Ensure tenant ID is properly set for patients, users, invitations, and patient-subject links in InvitationService; add corresponding unit tests. 2026-01-16 21:46:00 +01:00
oskar c65d1031ed Update Forgejo CI workflows to use full GitHub action URLs
All checks were successful
ci / changes (push) Successful in 21s
ci / backend (push) Successful in 3m3s
ci / flutter (push) Successful in 1m10s
2026-01-16 21:44:46 +01:00
3 changed files with 37 additions and 9 deletions

View file

@ -13,19 +13,20 @@ jobs:
changes:
runs-on: docker
steps:
- uses: actions/checkout@v4
- uses: https://github.com/actions/checkout@v4
with:
fetch-depth: 0
- id: filter
uses: dorny/paths-filter@v3
uses: https://github.com/dorny/paths-filter@v3
with:
list-files: shell
filters: |
backend:
- 'back001/**'
- '.forgejo/workflows/**'
- 'ci/**'
frontend:
- 'front001/**'
- '.forgejo/workflows/**'
- 'ci/**'
outputs:
backend: ${{ steps.filter.outputs.backend }}
@ -38,9 +39,9 @@ jobs:
container:
image: forgejo.okit.pl/oskar/ci-gradle-node:8.7-jdk17
steps:
- uses: actions/checkout@v4
- uses: https://github.com/actions/checkout@v4
- uses: actions/cache@v4
- uses: https://github.com/actions/cache@v4
with:
path: |
/home/gradle/.gradle/caches
@ -60,9 +61,9 @@ jobs:
container:
image: forgejo.okit.pl/oskar/ci-flutter-node:stable
steps:
- uses: actions/checkout@v4
- uses: https://github.com/actions/checkout@v4
- uses: actions/cache@v4
- uses: https://github.com/actions/cache@v4
with:
path: |
/root/.pub-cache

View file

@ -40,13 +40,15 @@ class InvitationService(
@Transactional
@PreAuthorize("hasRole('ADMIN')")
fun createPatientInvite(email: String, createdByAdmin: String?): InviteCreationResult {
requireNotNull(TenantContext.getTenantId()) { "Missing tenant" }
val tenantId = TenantContext.getTenantId() ?: throw IllegalArgumentException("Missing tenant")
val patient = Patient(UUID.randomUUID().toString(), generatePatientPlaceholderName())
patient.tenantId = tenantId
val savedPatient = patientRepository.save(patient)
keycloakProvisioningService.provisionUser(email, Invitation.ROLE_PATIENT)?.let { userId ->
val user = User(userId, email, Invitation.ROLE_PATIENT, "INVITED")
user.tenantId = tenantId
userRepository.save(user)
}
keycloakProvisioningService.sendSetPasswordEmail(email)
@ -64,6 +66,7 @@ class InvitationService(
acceptedBy = null,
createdByAdmin = createdByAdmin
)
invitation.tenantId = tenantId
invitationRepository.save(invitation)
return InviteCreationResult(token, invitation.expiresAt)
}
@ -103,6 +106,7 @@ class InvitationService(
throw IllegalArgumentException("Invitation email mismatch")
}
val newUser = User(authenticatedUserId, authenticatedEmail, invitation.role, "ACTIVE")
newUser.tenantId = TenantContext.getTenantId() ?: throw IllegalStateException("Missing tenant")
userRepository.save(newUser)
}
@ -140,6 +144,7 @@ class InvitationService(
val tenantId = TenantContext.getTenantId() ?: throw IllegalStateException("Missing tenant")
if (!subjectRepository.existsByTenantIdAndPatientIdAndUserId(tenantId, patientId, userId)) {
val link = PatientSubject(UUID.randomUUID().toString(), patientId, userId)
link.tenantId = tenantId
subjectRepository.save(link)
}
}

View file

@ -79,6 +79,28 @@ class InvitationServiceTest {
assertEquals(Invitation.STATUS_ACCEPTED, invitation.status)
assertNotNull(invitation.acceptedAt)
assertEquals(user, invitation.acceptedBy)
org.mockito.kotlin.verify(subjectRepository).save(org.mockito.kotlin.check {
assertEquals("t1", it.tenantId)
})
}
@Test
fun `creates patient invite with tenantId`() {
val email = "new@example.com"
whenever(patientRepository.save(any<Patient>())).thenAnswer { it.arguments[0] as Patient }
whenever(userRepository.save(any<User>())).thenAnswer { it.arguments[0] as User }
whenever(invitationRepository.save(any<Invitation>())).thenAnswer { it.arguments[0] as Invitation }
val result = service.createPatientInvite(email, "admin-1")
assertNotNull(result.token)
org.mockito.kotlin.verify(patientRepository).save(org.mockito.kotlin.check<Patient> {
assertEquals("t1", it.tenantId)
})
org.mockito.kotlin.verify(invitationRepository).save(org.mockito.kotlin.check<Invitation> {
assertEquals("t1", it.tenantId)
assertEquals(email, it.email)
})
}
@Test