From ad13ac86501737085e1423fb932ea52cb091aca1 Mon Sep 17 00:00:00 2001 From: amass Date: Wed, 8 Jan 2025 23:44:41 +0800 Subject: [PATCH] fix relogin error. --- WebApplication/CMakeLists.txt | 1 + WebApplication/LoginPage.cpp | 9 ++++++++ WebApplication/LoginPage.h | 1 + WebApplication/RegistrationPage.cpp | 14 ++++++++++++ WebApplication/RegistrationPage.h | 13 +++++++++++ resources/auth_css_theme.xml | 34 ++++++++++++++++++++++------- resources/auth_strings_zh.xml | 34 +++++++++++------------------ resources/wt_zh.xml | 16 +++++++------- 8 files changed, 85 insertions(+), 37 deletions(-) create mode 100644 WebApplication/RegistrationPage.cpp create mode 100644 WebApplication/RegistrationPage.h diff --git a/WebApplication/CMakeLists.txt b/WebApplication/CMakeLists.txt index 42627c2..e2b1dce 100644 --- a/WebApplication/CMakeLists.txt +++ b/WebApplication/CMakeLists.txt @@ -5,6 +5,7 @@ add_library(WebApplication BulmaTheme.h BulmaTheme.cpp HomePage.h HomePage.cpp LoginPage.h LoginPage.cpp + RegistrationPage.h RegistrationPage.cpp NavigationBar.h NavigationBar.cpp RedirectPage.h RedirectPage.cpp VisitorRecordsPage.h VisitorRecordsPage.cpp diff --git a/WebApplication/LoginPage.cpp b/WebApplication/LoginPage.cpp index 1d29ba3..6fdaba6 100644 --- a/WebApplication/LoginPage.cpp +++ b/WebApplication/LoginPage.cpp @@ -1,5 +1,6 @@ #include "LoginPage.h" #include "Application.h" +#include "RegistrationPage.h" #include "model/AuthModel.h" #include #include @@ -16,6 +17,14 @@ LoginPage::LoginPage(const Wt::Auth::AuthService &baseAuth, Wt::Auth::AbstractUs // setAttributeValue("style", "transform: translateY(-100px);"); } +std::unique_ptr LoginPage::createRegistrationView(const Wt::Auth::Identity &id) { + auto model = createRegistrationModel(); + if (id.isValid()) model->registerIdentified(id); + auto view = std::make_unique(this); + view->setModel(std::move(model)); + return view; +} + void LoginPage::processExternalEnvironment(const std::string &externalPath, Wt::Auth::AuthService &service) { using namespace Wt::Auth; std::string emailToken; diff --git a/WebApplication/LoginPage.h b/WebApplication/LoginPage.h index 58be829..2c6318e 100644 --- a/WebApplication/LoginPage.h +++ b/WebApplication/LoginPage.h @@ -7,6 +7,7 @@ class LoginPage : public Wt::Auth::AuthWidget { public: LoginPage(const Wt::Auth::AuthService &baseAuth, Wt::Auth::AbstractUserDatabase &users, Wt::Auth::Login &login); void processExternalEnvironment(const std::string &externalPath, Wt::Auth::AuthService &service); + std::unique_ptr createRegistrationView(const Wt::Auth::Identity &id) final; }; #endif // __LOGINWIDGET_H__ \ No newline at end of file diff --git a/WebApplication/RegistrationPage.cpp b/WebApplication/RegistrationPage.cpp new file mode 100644 index 0000000..ed659b4 --- /dev/null +++ b/WebApplication/RegistrationPage.cpp @@ -0,0 +1,14 @@ +#include "RegistrationPage.h" +#include "LoginPage.h" +#include + +RegistrationPage::RegistrationPage(LoginPage *authWidget) : Wt::Auth::RegistrationWidget(authWidget) { +} + +void RegistrationPage::update() { + Wt::Auth::RegistrationWidget::update(); + Wt::WAnchor *isYou = resolve("confirm-is-you"); + if (isYou != nullptr) { + isYou->setLink(Wt::WLink()); + } +} \ No newline at end of file diff --git a/WebApplication/RegistrationPage.h b/WebApplication/RegistrationPage.h new file mode 100644 index 0000000..c13cf9b --- /dev/null +++ b/WebApplication/RegistrationPage.h @@ -0,0 +1,13 @@ +#ifndef __REGISTRATIONPAGE_H__ +#define __REGISTRATIONPAGE_H__ + +#include + +class LoginPage; + +class RegistrationPage : public Wt::Auth::RegistrationWidget { +public: + RegistrationPage(LoginPage *authWidget = nullptr); + void update() final; +}; +#endif // __REGISTRATIONPAGE_H__ \ No newline at end of file diff --git a/resources/auth_css_theme.xml b/resources/auth_css_theme.xml index 6c51449..1cb6054 100644 --- a/resources/auth_css_theme.xml +++ b/resources/auth_css_theme.xml @@ -202,19 +202,37 @@
-

${tr:Wt.Auth.password-prompt-form-title}

+

${tr:Wt.Auth.password-prompt-form-title}

${tr:Wt.Auth.password-prompt-form-info}

-
-