Trying a long shot to fix bitid 2

This commit is contained in:
Falkvinge
2016-11-25 15:41:44 +01:00
parent 408dfe393e
commit fb24569e70
2 changed files with 13 additions and 10 deletions
+1 -1
View File
@@ -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;
}
+12 -9
View File
@@ -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);