From 5f6149b36dbfcfeef467d7cee919dbfe203b2abd Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Tue, 13 Dec 2016 21:07:10 +0100 Subject: [PATCH] Disabled simple login for BitID-enabled accounts --- .../Pages.Security.designer.cs | 11 ++++++++++- Site/App_GlobalResources/Pages.Security.resx | 3 +++ Site/Security/Login.aspx | 2 ++ Site/Security/Login.aspx.cs | 15 ++++++++++++++- 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Site/App_GlobalResources/Pages.Security.designer.cs b/Site/App_GlobalResources/Pages.Security.designer.cs index 96e902b7..60a596fe 100644 --- a/Site/App_GlobalResources/Pages.Security.designer.cs +++ b/Site/App_GlobalResources/Pages.Security.designer.cs @@ -19,7 +19,7 @@ namespace Resources.Pages { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option or rebuild the Visual Studio project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Web.Application.StronglyTypedResourceProxyBuilder", "11.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Web.Application.StronglyTypedResourceProxyBuilder", "14.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Security { @@ -250,6 +250,15 @@ namespace Resources.Pages { } } + /// + /// Looks up a localized string similar to <strong>BITID LOGIN REQUIRED</strong><br/><br/>This login requires BitId authentication, as enabled by the account holder. You cannot log on with a username/password combination.. + /// + internal static string Login_BitIdRequired_Dialog { + get { + return ResourceManager.GetString("Login_BitIdRequired_Dialog", resourceCulture); + } + } + /// /// Looks up a localized string similar to 2FA. /// diff --git a/Site/App_GlobalResources/Pages.Security.resx b/Site/App_GlobalResources/Pages.Security.resx index 15fd303e..941d22d1 100644 --- a/Site/App_GlobalResources/Pages.Security.resx +++ b/Site/App_GlobalResources/Pages.Security.resx @@ -182,6 +182,9 @@ <strong>BitId two-factor authentication is now enabled.</strong><br/><br/>From now on, you can use your bitcoin wallet to log in (and will <strong>need</strong> to do so). Thank you for enabling added security.<br/><br/>Please remember to keep your phone secure with a password, too. + + <strong>BITID LOGIN REQUIRED</strong><br/><br/>This login requires BitId authentication, as enabled by the account holder. You cannot log on with a username/password combination. + 2FA diff --git a/Site/Security/Login.aspx b/Site/Security/Login.aspx index 76ddcb4b..891cd511 100644 --- a/Site/Security/Login.aspx +++ b/Site/Security/Login.aspx @@ -115,6 +115,8 @@ } else if (msg.d == "Fail") { // inform user of bad credentials by means of a red cross on _both_ boxes $('#TextLogin, #TextPass').css('background-image', "url('/Security/Images/iconshock-cross-12px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat'); + } else if (msg.d == "BitIdRequired") { + alertify.alert(SwarmopsJS.unescape('<%=this.Localized_BitIdRequired_Dialog%>')); } else { // wut? } diff --git a/Site/Security/Login.aspx.cs b/Site/Security/Login.aspx.cs index 57c68c5c..068511e2 100644 --- a/Site/Security/Login.aspx.cs +++ b/Site/Security/Login.aspx.cs @@ -316,6 +316,14 @@ namespace Swarmops.Pages.Security Person authenticatedPerson = Authentication.Authenticate (credentialsLogin, credentialsPass); + if (!string.IsNullOrEmpty(authenticatedPerson.BitIdAddress)) + { + // We can't logon with username/password combo; bitID is activated and so + // require it. + + return "BitIdRequired"; + } + int lastOrgId = authenticatedPerson.LastLogonOrganizationId; if (PilotInstallationIds.IsPilot (PilotInstallationIds.PiratePartySE) && (lastOrgId == 3 || lastOrgId == 0)) @@ -348,7 +356,7 @@ namespace Swarmops.Pages.Security GuidCache.Set (logonUri + "-LoggedOn", Authority.FromLogin (authenticatedPerson, Organization.FromIdentity (lastOrgId)).ToEncryptedXml()); - return "Success"; // Prepare here for "2FARequired" return code + return "Success"; // Prepare here for "Additional2FARequired" return code } catch (UnauthorizedAccessException) { @@ -478,6 +486,11 @@ namespace Swarmops.Pages.Security public string signature { get; set; } } + public string Localized_BitIdRequired_Dialog + { + get { return Resources.Pages.Security.Login_BitIdRequired_Dialog; } + } + // ReSharper restore InconsistentNaming } } \ No newline at end of file