From 9107435be385ff900af9852d32da72befce24383 Mon Sep 17 00:00:00 2001
From: "Richard T. Carback III" <rick.carback@gmail.com>
Date: Thu, 3 Feb 2022 17:52:49 +0000
Subject: [PATCH] Create a brand new partnerContact object instead of trying to
 use the existing one.

---
 auth/callback.go | 29 +++++++++++++++++++++++------
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/auth/callback.go b/auth/callback.go
index 7d3f26216..7ae57d144 100644
--- a/auth/callback.go
+++ b/auth/callback.go
@@ -9,6 +9,8 @@ package auth
 
 import (
 	"fmt"
+	"strings"
+
 	"github.com/cloudflare/circl/dh/sidh"
 	"github.com/pkg/errors"
 	jww "github.com/spf13/jwalterweatherman"
@@ -26,7 +28,6 @@ import (
 	"gitlab.com/elixxir/primitives/fact"
 	"gitlab.com/elixxir/primitives/format"
 	"gitlab.com/xx_network/crypto/csprng"
-	"strings"
 )
 
 func (m *Manager) StartProcesses() (stoppable.Stoppable, error) {
@@ -185,7 +186,7 @@ func (m *Manager) handleRequest(cmixMsg format.Message,
 				events.Report(5, "Auth", "DuplicateRequest", em)
 				// if the caller of the API wants requests replayed,
 				// replay the duplicate request
-				if m.replayRequests{
+				if m.replayRequests {
 					cbList := m.requestCallbacks.Get(c.ID)
 					for _, cb := range cbList {
 						rcb := cb.(interfaces.RequestCallback)
@@ -229,12 +230,28 @@ func (m *Manager) handleRequest(cmixMsg format.Message,
 				}
 
 				// If I do, delete my request on disk
-				_, _, partnerContact, _ := m.storage.Auth().GetRequest(partnerID)
 				m.storage.Auth().Delete(partnerID)
 
-				// Use the public key sent to me, not the one I
-				// first retrieved to initiate the auth request
-				partnerContact.DhPubKey = partnerPubKey
+				//process the inner payload
+				facts, _, err := fact.UnstringifyFactList(
+					string(requestFmt.msgPayload))
+				if err != nil {
+					em := fmt.Sprintf("failed to parse facts and message "+
+						"from Auth Request: %s", err)
+					jww.WARN.Print(em)
+					events.Report(10, "Auth", "RequestError", em)
+					return
+				}
+
+				// create the contact, note that we use the data
+				// sent in the request and not any data we had
+				// already
+				partnerContact := contact.Contact{
+					ID:             partnerID,
+					DhPubKey:       partnerPubKey,
+					OwnershipProof: copySlice(ownership),
+					Facts:          facts,
+				}
 
 				// add a confirmation to disk
 				if err = m.storage.Auth().AddReceived(partnerContact,
-- 
GitLab