From 3943bbc4138c25996265b4f16d2111b793f82871 Mon Sep 17 00:00:00 2001 From: amass Date: Tue, 24 Dec 2024 23:46:20 +0800 Subject: [PATCH] verify email pass. --- UnitTest/CMakeLists.txt | 1 + UnitTest/MailTest.cpp | 25 +++++++++++++++++++++++++ WebApplication/Application.cpp | 8 +++++--- resources/auth_css_theme.xml | 25 +++++++++++++------------ resources/auth_strings_zh.xml | 12 +++++------- resources/wt_config.xml | 18 +++++++++--------- 6 files changed, 58 insertions(+), 31 deletions(-) create mode 100644 UnitTest/MailTest.cpp diff --git a/UnitTest/CMakeLists.txt b/UnitTest/CMakeLists.txt index 509f5c8..bc418f2 100644 --- a/UnitTest/CMakeLists.txt +++ b/UnitTest/CMakeLists.txt @@ -6,6 +6,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) add_executable(UnitTest main.cpp DatabaseTest.cpp + MailTest.cpp ) target_compile_definitions(UnitTest diff --git a/UnitTest/MailTest.cpp b/UnitTest/MailTest.cpp new file mode 100644 index 0000000..8e2d1f6 --- /dev/null +++ b/UnitTest/MailTest.cpp @@ -0,0 +1,25 @@ +#include "BoostLog.h" +#include +#include +#include +#include + +// BOOST_AUTO_TEST_CASE(MailTest) { +// Wt::Mail::Client client; +// client.enableAuthentication("17688947728@163.com", "yourpassword", Wt::Mail::AuthenticationMethod::Login); +// client.setTransportEncryption(Wt::Mail::TransportEncryption::TLS); +// LOG(info) << client.connect("smtp.163.com", 465); + +// Wt::Mail::Mailbox from("17688947728@163.com"); + +// Wt::Mail::Mailbox to("168062547@qq.com"); + +// Wt::Mail::Message message; +// message.setFrom(from); +// message.addRecipient(Wt::Mail:: RecipientType::To,to); +// message.setReplyTo(to); +// message.setSubject(Wt::WString::fromUTF8("Hey there, \xe2\x82\xac !")); + +// message.setBody("你好"); +// LOG(info) << client.send(message); +// } \ No newline at end of file diff --git a/WebApplication/Application.cpp b/WebApplication/Application.cpp index 6dbf99c..666b48c 100644 --- a/WebApplication/Application.cpp +++ b/WebApplication/Application.cpp @@ -33,10 +33,10 @@ Application::Application(const Wt::WEnvironment &env, bool embedded) : Wt::WAppl setTheme(std::make_shared("bulma", !embedded)); if (!embedded) { m_navigationBar = root()->addNew(); - m_navigationBar->registerClicked.connect([this](){ - if(m_loginPage){ + m_navigationBar->registerClicked.connect([this]() { + if (m_loginPage) { m_loginPage->registerNewUser(); - } else if(m_loginPageRef){ + } else if (m_loginPageRef) { m_loginPageRef->registerNewUser(); } }); @@ -155,6 +155,8 @@ Server::~Server() { void Server::initializeAuthenticationService() { m_authService = std::make_unique(); + m_authService->setEmailVerificationEnabled(true); + m_authService->setEmailVerificationRequired(true); m_authService->setAuthTokensEnabled(true, "logincookie"); m_passwordService = std::make_unique(*m_authService); diff --git a/resources/auth_css_theme.xml b/resources/auth_css_theme.xml index a9d98dc..951aca1 100644 --- a/resources/auth_css_theme.xml +++ b/resources/auth_css_theme.xml @@ -48,18 +48,18 @@ ${} ${} - } ${} ${} -

Or use:

${icons} @@ -67,12 +67,12 @@ ${} -
+
${login}
-
- ${lost-password} ${sep} +
+ ${lost-password class="has-text-link is-pointer-cursor"} ${sep} ${register class="has-text-link is-pointer-cursor"}
@@ -186,14 +186,15 @@

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

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

-
- - ${email} +
+ +
+ ${email class="bulma-input"} +
+

${tr:Wt.Auth.email-info}

-
+
${send-button} ${cancel-button}
diff --git a/resources/auth_strings_zh.xml b/resources/auth_strings_zh.xml index 18b6709..5c9a33a 100644 --- a/resources/auth_strings_zh.xml +++ b/resources/auth_strings_zh.xml @@ -84,7 +84,7 @@ 保持登录状态{1}周 Keeps login for {1} - Lost password + 忘记密码 登录 退出 {1}s后重试 @@ -143,12 +143,10 @@ - Forgot your password? No sweat! - Recover your password - Please enter below the - email address which you used during registration. A mail will be - sent with instructions to enter a new password. - Send + 忘记密码了? 不用担心! + 重置密码 + 请输入注册时使用的邮箱,稍后将发送一封邮件至您的邮箱以重置密码。 + 发送 diff --git a/resources/wt_config.xml b/resources/wt_config.xml index 587b469..00957b7 100644 --- a/resources/wt_config.xml +++ b/resources/wt_config.xml @@ -687,13 +687,13 @@ - smtp-auth-username: the username to use for authentication (defaults to empty) - smtp-auth-password: the password to use for authentication (defaults to empty) --> - - - - - - - + smtp.qq.com + 465 + amass.fun + tls + login + 168062547@qq.com + your_password - - + amass + 168062547@qq.com