From fb24569e709da1d246e8862f0137036fe9cd80f5 Mon Sep 17 00:00:00 2001 From: Falkvinge Date: Fri, 25 Nov 2016 15:41:44 +0100 Subject: [PATCH] Trying a long shot to fix bitid 2 --- Site/Master-v5.master.cs | 2 +- Site/Security/Login.aspx.cs | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Site/Master-v5.master.cs b/Site/Master-v5.master.cs index f90682b5..2001cba4 100644 --- a/Site/Master-v5.master.cs +++ b/Site/Master-v5.master.cs @@ -525,7 +525,7 @@ namespace Swarmops.Frontend bitIdUri += "&u=1"; } - GuidCache.Set(bitIdUri + "-Intent", "Register"); // Intent: register BitID + GuidCache.Set(bitIdUri + "-Intent", "Register-" + CurrentUser.Identity.ToString(CultureInfo.InvariantCulture)); // Intent: register BitID return bitIdUri; } diff --git a/Site/Security/Login.aspx.cs b/Site/Security/Login.aspx.cs index 04e019af..95724b2e 100644 --- a/Site/Security/Login.aspx.cs +++ b/Site/Security/Login.aspx.cs @@ -203,7 +203,6 @@ namespace Swarmops.Pages.Security protected static void ProcessRespondBitId (BitIdCredentials credentials, HttpResponse response) { - AuthenticationData authData = GetAuthenticationDataAndCulture(); BitcoinPubKeyAddress testAddress = new BitcoinPubKeyAddress (credentials.address); if (testAddress.VerifyMessage (credentials.uri, credentials.signature)) @@ -212,19 +211,23 @@ namespace Swarmops.Pages.Security try { - if (authData.CurrentUser != null) + // Test for registration + + string intent = GuidCache.Get(credentials.uri + "-Intent") as string; + + if (!string.IsNullOrEmpty(intent)) { - if ((string) GuidCache.Get (credentials.uri + "-Intent") == "Register") + if (intent.StartsWith("Register")) { - // the currently logged-on user desires to register this address - // so set currentUser bitid - authData.CurrentUser.BitIdAddress = credentials.address; - // Then go do something else, I guess? Flag somehow to original page - // that the op is completed? - GuidCache.Set (credentials.uri + "-Intent", "Complete"); + int personId = Int32.Parse(intent.Substring("Register-".Length)); + Person person = Person.FromIdentity(personId); + person.BitIdAddress = credentials.address; + GuidCache.Set(credentials.uri + "-Intent", "Complete"); } } + // Otherwise, test for logon + if (GuidCache.Get (credentials.uri + "-Logon") as string == "Unauth") { Person person = Person.FromBitIdAddress (credentials.address);