The Unified and Autonomous Development Platform
feat: Show key in addition to QR code when setting up 2FA (OD-2475)
Robin Shen8a49596a6abd
diff --git a/server-core/src/main/java/io/onedev/server/web/component/user/twofactorauthentication/TwoFactorAuthenticationSetupPanel.html b/server-core/src/main/java/io/onedev/server/web/component/user/twofactorauthentication/TwoFactorAuthenticationSetupPanel.htmlindex be4495dde9..4b3ae57123 100644--- a/server-core/src/main/java/io/onedev/server/web/component/user/twofactorauthentication/TwoFactorAuthenticationSetupPanel.html+++ b/server-core/src/main/java/io/onedev/server/web/component/user/twofactorauthentication/TwoFactorAuthenticationSetupPanel.html@@ -14,6 +14,15 @@<img wicket:id="QRCode"></div>+ <div class="text-secondary font-size-lg font-weight-boldest mb-2">+ <wicket:t>Or manually enter the secret key below in your authenticator app</wicket:t>+ </div>+ <div class="d-flex justify-content-center mb-3">+ <div class="text-monospace font-weight-bold border rounded p-2">+ <span wicket:id="secretKey"></span>+ </div>+ </div>+<div class="text-secondary font-size-lg font-weight-boldest mb-2"><wicket:t>Then enter the passcode shown in the TOTP authenticator to verify</wicket:t></div>diff --git a/server-core/src/main/java/io/onedev/server/web/component/user/twofactorauthentication/TwoFactorAuthenticationSetupPanel.java b/server-core/src/main/java/io/onedev/server/web/component/user/twofactorauthentication/TwoFactorAuthenticationSetupPanel.javaindex fb56b389d4..922e9fbd6a 100644--- a/server-core/src/main/java/io/onedev/server/web/component/user/twofactorauthentication/TwoFactorAuthenticationSetupPanel.java+++ b/server-core/src/main/java/io/onedev/server/web/component/user/twofactorauthentication/TwoFactorAuthenticationSetupPanel.java@@ -97,6 +97,8 @@ public abstract class TwoFactorAuthenticationSetupPanel extends GenericPanel<Use});+ form.add(new Label("secretKey", authentication.getSecretKey()));+TextField<String> input = new TextField<String>("passcode", Model.of(""));form.add(input);form.add(new FencedFeedbackPanel("feedback", form));diff --git a/server-core/src/main/java/io/onedev/server/web/component/user/twofactorauthentication/TwoFactorAuthenticationStatusPanel.html b/server-core/src/main/java/io/onedev/server/web/component/user/twofactorauthentication/TwoFactorAuthenticationStatusPanel.htmlindex 29b9eef52c..973a3c6c2e 100644--- a/server-core/src/main/java/io/onedev/server/web/component/user/twofactorauthentication/TwoFactorAuthenticationStatusPanel.html+++ b/server-core/src/main/java/io/onedev/server/web/component/user/twofactorauthentication/TwoFactorAuthenticationStatusPanel.html@@ -2,13 +2,15 @@<div wicket:id="content"></div><wicket:fragment wicket:id="configuredFrag"><div class="alert alert-notice alert-light-success mb-0">- Two-factor authentication already set up. <a wicket:id="requestToSetupAgain">Request to set up again</a> in case+ <wicket:t>+ Two-factor authentication already set up. <a wicket:id="requestToSetupAgain"><wicket:t>Request to set up again</wicket:t></a> in caseboth TOTP authenticator and access codes are lost+ </wicket:t></div></wicket:fragment><wicket:fragment wicket:id="notConfiguredFrag"><div class="alert alert-notice alert-light-warning mb-0">- Will be prompted to set up two-factor authentication upon next login+ <wicket:t>Will be prompted to set up two-factor authentication upon next login</wicket:t></div></wicket:fragment></wicket:panel>\ No newline at end of filediff --git a/server-core/src/main/java/io/onedev/server/web/page/my/twofactorauthentication/MyTwoFactorAuthenticationPage.java b/server-core/src/main/java/io/onedev/server/web/page/my/twofactorauthentication/MyTwoFactorAuthenticationPage.javaindex 89a8b8dc7b..c06fa983b6 100644--- a/server-core/src/main/java/io/onedev/server/web/page/my/twofactorauthentication/MyTwoFactorAuthenticationPage.java+++ b/server-core/src/main/java/io/onedev/server/web/page/my/twofactorauthentication/MyTwoFactorAuthenticationPage.java@@ -4,6 +4,9 @@ import io.onedev.commons.utils.ExplicitException;import io.onedev.server.model.User;import io.onedev.server.web.component.user.twofactorauthentication.TwoFactorAuthenticationStatusPanel;import io.onedev.server.web.page.my.MyPage;++import static io.onedev.server.web.translation.Translation._T;+import org.apache.wicket.Component;import org.apache.wicket.markup.html.basic.Label;import org.apache.wicket.request.mapper.parameter.PageParameters;@@ -15,7 +18,7 @@ public class MyTwoFactorAuthenticationPage extends MyPage {if (getUser().isServiceAccount() || getUser().isDisabled())throw new IllegalStateException();else if (!getUser().isEnforce2FA())- throw new ExplicitException("Two-factor authentication not enabled");+ throw new ExplicitException(_T("Two-factor authentication not enabled"));}@Override@@ -32,7 +35,7 @@ public class MyTwoFactorAuthenticationPage extends MyPage {@Overrideprotected Component newTopbarTitle(String componentId) {- return new Label(componentId, "Two Factor Authentication");+ return new Label(componentId, _T("Two Factor Authentication"));}}