@startuml
<style>
activityDiagram {
  diamond {
    FontColor black
    BackgroundColor #ccf
  }
}
</style>

start
:Property owner submits
an __invitation form__ specifying
email address;
if (\n\nDoes User with given\nemail exist in the db?\n\n) then (yes)
	:Fetch User;
	:Create an invitation record in db
	(__with__ user_id);
	:Send invitation email to the User
	(click to accept the invitation);
else (no)
	:Create invitation record in db
	(__without__ user_id);
	:Send invitation email to the User
	(click to register account and accept the invitation);
endif

:User clicks an invitation link\n(token in URL);
:Fetch invitation record by the token;
if (\n\nDoes the invitation exist?\n\n) then (yes)
	if (\n\nIs user_id present\nand\nUser exist in the db?\n\n) then (yes)
		:Associate the User with the property owner;
		:Delete the invitation record;
		:Redirect the User\nto the login page or to the dashboard;
		:Display:\nThe invitation has been confirmed;
		stop
	else (no)
		:Render a dedicated Register User page;
		note right
			Prompt User for password,
			Auto fill the already known fields.
			Email field is disabled (can not be changed)
			as it would complicate the logic.
		end note
		:Create User record;
		note right
			No need to send confirmation email
			(the fact that User clicked the invitation
			link is a confirmation)
		end note
		:Associate the User with the property owner;
		:Delete the invitation record;
		:Auto log in the User\nand redirect to the dashboard;
		:Display:\nThe invitation has been confirmed;
		stop
	endif
else (no)
	:Display:
	The invitation link is invalid,
	expired, or was already used;
end


@enduml

Download flow.puml

flow.puml rendered as SVG flow.puml rendered as SVG
Rendered diagram

PlantUML draws diagrams from plain text. Paste the source into the online server, or render it locally with plantuml -tsvg flow.puml.