Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f68a09b
PDJB-260: Fix local-auth profile
JasminConterioSW May 28, 2026
92bd70f
PDJB-260: Refactor landlord registration journey
JasminConterioSW Jun 1, 2026
a017af4
PDJB-260: Update the journey map
JasminConterioSW May 28, 2026
ffd8baa
PDJB-260: Re-jig so that multiple invitation tokens / journey can be …
JasminConterioSW May 29, 2026
e8c75fe
PDJB-260: Add Landlord Registration task into invitation acceptance j…
JasminConterioSW Jun 1, 2026
37c593c
fixup! PDJB-260: Refactor landlord registration journey
JasminConterioSW Jun 1, 2026
2a3476d
PDJB-260: update journey tests to include landlord registration journ…
JasminConterioSW May 29, 2026
f6dd123
fixup! PDJB-260: update journey tests to include landlord registratio…
JasminConterioSW Jun 1, 2026
2ad29da
PDJB-260: Update controller tests
JasminConterioSW Jun 1, 2026
db14a64
PDJB-260: Update service tests
JasminConterioSW Jun 1, 2026
82fd4dd
PDJB-260: Tidy up names
JasminConterioSW Jun 1, 2026
4961bd0
PDJB-260: Separate out LandlordRegistrationState to use in both journeys
JasminConterioSW Jun 2, 2026
808aad1
PDJB-260: Add CYA journey map and stop checking invitationToken on al…
JasminConterioSW Jun 2, 2026
bd851b8
PDJB-260: Update controller tests
JasminConterioSW Jun 2, 2026
6a97f3f
PDJB-260: Revert accidental change to local.run.xml
JasminConterioSW Jun 2, 2026
f8b3d02
PDJB-260: Remove unused JOURNEY_ID request param from controller endp…
JasminConterioSW Jun 2, 2026
4201983
PDJB-260: Move auth check to the stepconfig and update tests
JasminConterioSW Jun 2, 2026
b6cc320
PDJB-260: Remove TODOs
JasminConterioSW Jun 2, 2026
e360e31
PDJB-260: Move cya journey steps to the LandlordRegistrationTask.kt t…
JasminConterioSW Jun 3, 2026
80b946b
PDJB-260: Update LandlordSecurityConfig to specify which journey urls…
JasminConterioSW Jun 3, 2026
81f97db
PDJB-260: Throw "Bad request" if a user tries to access the journey f…
JasminConterioSW Jun 3, 2026
3c248e9
PDJB-260: Updating journey seeding so that the invite link can start …
JasminConterioSW Jun 3, 2026
d0133e1
PDJB-260: Add controller tests
JasminConterioSW Jun 3, 2026
9afd5ab
PDJB-260: Update so if the journey is not initialised we direct to th…
JasminConterioSW Jun 3, 2026
951244c
PDJB-260: Update acceptOrRejectStep to use nextDestination
JasminConterioSW Jun 3, 2026
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
Expand Up @@ -28,10 +28,14 @@ import uk.gov.communities.prsdb.webapp.config.security.DefaultSecurityConfig.Com
import uk.gov.communities.prsdb.webapp.config.security.DefaultSecurityConfig.Companion.PERMISSIONS_POLICY_DIRECTIVES
import uk.gov.communities.prsdb.webapp.constants.OneLoginClaimKeys
import uk.gov.communities.prsdb.webapp.controllers.AcceptOrRejectJointLandlordInvitationController
import uk.gov.communities.prsdb.webapp.controllers.AcceptOrRejectJointLandlordInvitationController.Companion.INVITATION_REJECTED_PATH_SEGMENT
import uk.gov.communities.prsdb.webapp.controllers.BetaFeedbackController
import uk.gov.communities.prsdb.webapp.controllers.LandlordPrivacyNoticeController
import uk.gov.communities.prsdb.webapp.controllers.PasscodeEntryController
import uk.gov.communities.prsdb.webapp.controllers.RegisterLandlordController
import uk.gov.communities.prsdb.webapp.journeys.acceptOrRejectJointLandlordInvitation.steps.AcceptOrRejectStep
import uk.gov.communities.prsdb.webapp.journeys.acceptOrRejectJointLandlordInvitation.steps.InviteUnavailableStep
import uk.gov.communities.prsdb.webapp.journeys.acceptOrRejectJointLandlordInvitation.steps.ValidateTokenStep
import uk.gov.communities.prsdb.webapp.journeys.landlordRegistration.stepConfig.IdentityVerifyingStep
import uk.gov.communities.prsdb.webapp.services.UserRolesService

Expand Down Expand Up @@ -66,9 +70,21 @@ class LandlordSecurityConfig(
.requestMatchers(AcceptOrRejectJointLandlordInvitationController.ACCEPT_OR_REJECT_JOINT_LANDLORD_INVITATION_ROUTE)
.permitAll()
.requestMatchers(
"${AcceptOrRejectJointLandlordInvitationController.ACCEPT_OR_REJECT_JOINT_LANDLORD_INVITATION_ROUTE}/**",
)
.permitAll()
AcceptOrRejectJointLandlordInvitationController.ACCEPT_OR_REJECT_JOINT_LANDLORD_INVITATION_ROUTE +
"/${ValidateTokenStep.ROUTE_SEGMENT}",
).permitAll()
.requestMatchers(
AcceptOrRejectJointLandlordInvitationController.ACCEPT_OR_REJECT_JOINT_LANDLORD_INVITATION_ROUTE +
"/${InviteUnavailableStep.ROUTE_SEGMENT}",
).permitAll()
.requestMatchers(
AcceptOrRejectJointLandlordInvitationController.ACCEPT_OR_REJECT_JOINT_LANDLORD_INVITATION_ROUTE +
"/${AcceptOrRejectStep.ROUTE_SEGMENT}",
).permitAll()
.requestMatchers(
AcceptOrRejectJointLandlordInvitationController.ACCEPT_OR_REJECT_JOINT_LANDLORD_INVITATION_ROUTE +
"/$INVITATION_REJECTED_PATH_SEGMENT",
).permitAll()
Comment thread
JasminConterioSW marked this conversation as resolved.
.anyRequest()
.authenticated()
}.oauth2Login { oauth ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package uk.gov.communities.prsdb.webapp.constants

const val LOCAL_COUNCIL_USER_INVITATION_TOKEN: String = "local-council-user-invitation-token"

const val JOINT_LANDLORD_INVITATION_TOKEN: String = "joint-landlord-invitation-token"

const val LOCAL_COUNCIL_USER_ID = "local-council-user-id"

const val PROPERTY_REGISTRATION_NUMBER = "propertyRegistrationNumber"
Expand Down Expand Up @@ -33,3 +31,8 @@ const val LOCAL_COUNCIL_USERS_INVITED_THIS_SESSION = "localCouncilUsersInvitedTh
const val INCOMPLETE_PROPERTY_FORM_CONTEXTS_DELETED_THIS_SESSION = "incompletePropertyFormContextsDeletedThisSession"

const val VERIFIED_IDENTITY_CACHE_KEY = "verified-identity-cache"

const val USER_SENT_TO_LANDLORD_REGISTRATION_WHILE_ACCEPTING_JOINT_LANDLORD_INVITATION =
"userSentToLandlordRegistrationWhileAcceptingJointLandlordInvitation"

const val JOINT_LANDLORD_INVITATION_TOKEN_WITH_ACCEPTANCE_JOURNEY_IDS = "jointLandlordInvitationTokenWithAcceptanceJourneyIds"
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ const val CHECKING_ANSWERS_FOR_PARAMETER_NAME = "checkingAnswersFor"
const val WITH_BACK_URL_PARAMETER_NAME = "withBackUrl"
const val CONTEXT_ID_URL_PARAMETER = "contextId"
const val TOKEN = "token"
const val JOURNEY_ID = "journeyId"
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,47 @@ import uk.gov.communities.prsdb.webapp.constants.JOINT_LANDLORD_INVITATION_PATH_
import uk.gov.communities.prsdb.webapp.constants.LANDLORD_PATH_SEGMENT
import uk.gov.communities.prsdb.webapp.constants.TOKEN
import uk.gov.communities.prsdb.webapp.controllers.AcceptOrRejectJointLandlordInvitationController.Companion.ACCEPT_OR_REJECT_JOINT_LANDLORD_INVITATION_ROUTE
import uk.gov.communities.prsdb.webapp.exceptions.PrsdbWebException
import uk.gov.communities.prsdb.webapp.journeys.FormData
import uk.gov.communities.prsdb.webapp.journeys.JourneyStateService
import uk.gov.communities.prsdb.webapp.journeys.NoSuchJourneyException
import uk.gov.communities.prsdb.webapp.journeys.acceptOrRejectJointLandlordInvitation.AcceptOrRejectJointLandlordInvitationJourneyFactory
import uk.gov.communities.prsdb.webapp.journeys.acceptOrRejectJointLandlordInvitation.steps.ValidateTokenStep
import uk.gov.communities.prsdb.webapp.services.JointLandlordInvitationService
import uk.gov.communities.prsdb.webapp.services.UserRolesService

@PrsdbController
@RequestMapping(ACCEPT_OR_REJECT_JOINT_LANDLORD_INVITATION_ROUTE)
class AcceptOrRejectJointLandlordInvitationController(
private val journeyFactory: AcceptOrRejectJointLandlordInvitationJourneyFactory,
private val invitationService: JointLandlordInvitationService,
private val userRolesService: UserRolesService,
) {
@GetMapping
@AvailableWhenFeatureEnabled(JOINT_LANDLORDS)
fun startJourney(
@RequestParam(value = TOKEN, required = true) token: String,
): ModelAndView {
invitationService.storeTokenInSession(token)
return initializeAndRedirect(
token,
ValidateTokenStep.ROUTE_SEGMENT,
"${ACCEPT_OR_REJECT_JOINT_LANDLORD_INVITATION_ROUTE}/${ValidateTokenStep.ROUTE_SEGMENT}",
)
val journeyId = journeyFactory.initializeJourneyState(token)
invitationService.addJourneyIdInvitationTokenPairToSession(journeyId, token)
val redirectUrl =
JourneyStateService.urlWithJourneyState(
"${ACCEPT_OR_REJECT_JOINT_LANDLORD_INVITATION_ROUTE}/${ValidateTokenStep.ROUTE_SEGMENT}",
journeyId,
)
return ModelAndView("redirect:$redirectUrl")
}

@GetMapping("/{stepRouteSegment}")
@AvailableWhenFeatureEnabled(JOINT_LANDLORDS)
fun getJourneyStep(
@PathVariable stepRouteSegment: String,
): ModelAndView {
val token = invitationService.getTokenFromSession() ?: throw(PrsdbWebException("Token not found in session"))
return try {
val journeyMap = journeyFactory.createJourneySteps(token)
journeyMap[stepRouteSegment]?.getStepModelAndView()
try {
val journeyMap = journeyFactory.createJourneySteps()
return journeyMap[stepRouteSegment]?.getStepModelAndView()
?: throw ResponseStatusException(HttpStatus.NOT_FOUND, "Step not found")
} catch (_: NoSuchJourneyException) {
initializeAndRedirect(token, stepRouteSegment)
return ModelAndView("redirect:$ACCEPT_OR_REJECT_JOINT_LANDLORD_INVITATION_ROUTE")
}
}

Expand All @@ -66,13 +68,12 @@ class AcceptOrRejectJointLandlordInvitationController(
@PathVariable stepRouteSegment: String,
@RequestParam formData: FormData,
): ModelAndView {
val token = invitationService.getTokenFromSession() ?: throw (PrsdbWebException("Token not found in session"))
return try {
val journeyMap = journeyFactory.createJourneySteps(token)
journeyMap[stepRouteSegment]?.postStepModelAndView(formData)
try {
val journeyMap = journeyFactory.createJourneySteps()
return journeyMap[stepRouteSegment]?.postStepModelAndView(formData)
?: throw ResponseStatusException(HttpStatus.NOT_FOUND, "Step not found")
} catch (_: NoSuchJourneyException) {
initializeAndRedirect(token, stepRouteSegment)
return ModelAndView("redirect:$ACCEPT_OR_REJECT_JOINT_LANDLORD_INVITATION_ROUTE")
}
}

Expand All @@ -93,16 +94,6 @@ class AcceptOrRejectJointLandlordInvitationController(
return ModelAndView("placeholder")
}

private fun initializeAndRedirect(
token: String,
stepRouteSegment: String,
path: String = stepRouteSegment,
): ModelAndView {
val journeyId = journeyFactory.initializeJourneyState(token)
val redirectUrl = JourneyStateService.urlWithJourneyState(path, journeyId)
return ModelAndView("redirect:$redirectUrl")
}

companion object {
const val PROPERTY_JOINED_CONFIRMATION_PATH_SEGMENT = "property-joined-$CONFIRMATION_PATH_SEGMENT"

Expand Down
Loading
Loading