From bff60953f36f87706546e49cd38fd7fc93727efa Mon Sep 17 00:00:00 2001
From: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
Date: Wed, 17 Jul 2019 04:55:25 +0100
Subject: Prevent duplicate entries in the completed registration flows (#741)

---
 clientapi/routing/register.go | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/clientapi/routing/register.go b/clientapi/routing/register.go
index 243f9dd2..fa15f4fc 100644
--- a/clientapi/routing/register.go
+++ b/clientapi/routing/register.go
@@ -85,6 +85,12 @@ func (d sessionsDict) GetCompletedStages(sessionID string) []authtypes.LoginType
 
 // AddCompletedStage records that a session has completed an auth stage.
 func (d *sessionsDict) AddCompletedStage(sessionID string, stage authtypes.LoginType) {
+	// Return if the stage is already present
+	for _, completedStage := range d.GetCompletedStages(sessionID) {
+		if completedStage == stage {
+			return
+		}
+	}
 	d.sessions[sessionID] = append(d.GetCompletedStages(sessionID), stage)
 }
 
-- 
cgit v1.2.3