Prevent duplicate entries in the completed registration flows (#741)

This commit is contained in:
Andrew Morgan 2019-07-17 04:55:25 +01:00 committed by Alex Chen
parent c494d81235
commit bff60953f3

View File

@ -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)
}