From 054cc630e94df6c5262eff4df8ded1b3bf32f16c Mon Sep 17 00:00:00 2001 From: Slendy Date: Sun, 29 Sep 2024 16:42:41 -0500 Subject: [PATCH] Allow users to manually setup two factor with secret key --- .../StringLists/TwoFactorStrings.cs | 4 +++ ProjectLighthouse.Localization/TwoFactor.resx | 12 +++++++++ .../Pages/TwoFactor/SetupTwoFactorPage.cshtml | 27 +++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/ProjectLighthouse.Localization/StringLists/TwoFactorStrings.cs b/ProjectLighthouse.Localization/StringLists/TwoFactorStrings.cs index 307ad97d5..799588003 100644 --- a/ProjectLighthouse.Localization/StringLists/TwoFactorStrings.cs +++ b/ProjectLighthouse.Localization/StringLists/TwoFactorStrings.cs @@ -24,6 +24,10 @@ public static class TwoFactorStrings public static readonly TranslatableString QrTitle = create("qr_title"); public static readonly TranslatableString QrDescription = create("qr_description"); + public static readonly TranslatableString QrAlternativeDescription = create("qr_alternative"); + public static readonly TranslatableString QrAlternativeCopy = create("qr_alternative_copy"); + public static readonly TranslatableString QrAlternativeCopySuccess = create("qr_alternative_copy_success"); + public static readonly TranslatableString QrAlternativeCopyFail = create("qr_alternative_copy_success"); private static TranslatableString create(string key) => new(TranslationAreas.TwoFactor, key); } \ No newline at end of file diff --git a/ProjectLighthouse.Localization/TwoFactor.resx b/ProjectLighthouse.Localization/TwoFactor.resx index 21d78ec4e..45845e8f5 100644 --- a/ProjectLighthouse.Localization/TwoFactor.resx +++ b/ProjectLighthouse.Localization/TwoFactor.resx @@ -66,4 +66,16 @@ Invalid Backup Code + + Can't use the QR code? You can use this secret key instead: + + + Copy secret code + + + Copied to clipboard + + + Failed to copy to clipboard + \ No newline at end of file diff --git a/ProjectLighthouse.Servers.Website/Pages/TwoFactor/SetupTwoFactorPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/TwoFactor/SetupTwoFactorPage.cshtml index 736e258e7..9a6fcf486 100644 --- a/ProjectLighthouse.Servers.Website/Pages/TwoFactor/SetupTwoFactorPage.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/TwoFactor/SetupTwoFactorPage.cshtml @@ -18,6 +18,9 @@

@Model.Translate(TwoFactorStrings.QrTitle)

2 Factor QR Code

@Model.Translate(TwoFactorStrings.QrDescription)

+

@Model.Translate(TwoFactorStrings.QrAlternativeDescription)

+ @Model.User?.TwoFactorSecret + @await Html.PartialAsync("Partials/TwoFactorPartial", new ViewDataDictionary(ViewData) { { @@ -31,6 +34,28 @@ }, }) + } else { @@ -83,5 +108,7 @@ else document.body.removeChild(elem); } } + + } \ No newline at end of file