verify email pass.
All checks were successful
Deploy / Build (push) Successful in 7m48s

This commit is contained in:
amass 2024-12-24 23:46:20 +08:00
parent 3228553be5
commit 3943bbc413
6 changed files with 58 additions and 31 deletions

View File

@ -6,6 +6,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_executable(UnitTest main.cpp add_executable(UnitTest main.cpp
DatabaseTest.cpp DatabaseTest.cpp
MailTest.cpp
) )
target_compile_definitions(UnitTest target_compile_definitions(UnitTest

25
UnitTest/MailTest.cpp Normal file
View File

@ -0,0 +1,25 @@
#include "BoostLog.h"
#include <Wt/Mail/Client.h>
#include <Wt/Mail/Mailbox.h>
#include <Wt/Mail/Message.h>
#include <boost/test/unit_test.hpp>
// 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);
// }

View File

@ -33,10 +33,10 @@ Application::Application(const Wt::WEnvironment &env, bool embedded) : Wt::WAppl
setTheme(std::make_shared<BulmaTheme>("bulma", !embedded)); setTheme(std::make_shared<BulmaTheme>("bulma", !embedded));
if (!embedded) { if (!embedded) {
m_navigationBar = root()->addNew<NavigationBar>(); m_navigationBar = root()->addNew<NavigationBar>();
m_navigationBar->registerClicked.connect([this](){ m_navigationBar->registerClicked.connect([this]() {
if(m_loginPage){ if (m_loginPage) {
m_loginPage->registerNewUser(); m_loginPage->registerNewUser();
} else if(m_loginPageRef){ } else if (m_loginPageRef) {
m_loginPageRef->registerNewUser(); m_loginPageRef->registerNewUser();
} }
}); });
@ -155,6 +155,8 @@ Server::~Server() {
void Server::initializeAuthenticationService() { void Server::initializeAuthenticationService() {
m_authService = std::make_unique<Wt::Auth::AuthService>(); m_authService = std::make_unique<Wt::Auth::AuthService>();
m_authService->setEmailVerificationEnabled(true);
m_authService->setEmailVerificationRequired(true);
m_authService->setAuthTokensEnabled(true, "logincookie"); m_authService->setAuthTokensEnabled(true, "logincookie");
m_passwordService = std::make_unique<Wt::Auth::PasswordService>(*m_authService); m_passwordService = std::make_unique<Wt::Auth::PasswordService>(*m_authService);

View File

@ -48,18 +48,18 @@
${</if:password>} ${</if:password>}
${<if:remember-me>} ${<if:remember-me>}
<div class="bulma-field bulma-is-grouped bulma-is-grouped-right">
<label for="${id:remember-me}"> <label for="${id:remember-me}">
${remember-me} ${remember-me}
${tr:Wt.Auth.remember-me} ${tr:Wt.Auth.remember-me}
${remember-me-info class="Wt-info bulma-help"} ${remember-me-info class="Wt-info bulma-help"}
</label> </label>
</div>
${</if:remember-me>} ${</if:remember-me>}
${</if:passwords>} ${</if:passwords>}
${<if:oauth>} ${<if:oauth>}
<div class="Wt-col-right"> <div class="Wt-col-right">
<h3>Or use:</h3> <h3>Or use:</h3>
${icons} ${icons}
@ -67,12 +67,12 @@
${</if:oauth>} ${</if:oauth>}
<div class="Wt-buttons"> <div class="bulma-field bulma-is-grouped bulma-is-grouped-centered">
${login} ${login}
</div> </div>
<div class="Wt-buttons"> <div class="bulma-field bulma-is-grouped bulma-is-grouped-right">
${lost-password} ${sep} ${lost-password class="has-text-link is-pointer-cursor"} ${sep}
${register class="has-text-link is-pointer-cursor"} ${register class="has-text-link is-pointer-cursor"}
</div> </div>
</div> </div>
@ -186,14 +186,15 @@
<h2>${tr:Wt.Auth.lost-password-form-title}</h2> <h2>${tr:Wt.Auth.lost-password-form-title}</h2>
<p>${tr:Wt.Auth.lost-password-form-info}</p> <p>${tr:Wt.Auth.lost-password-form-info}</p>
<div class="Wt-fields"> <div class="bulma-field">
<label for="${id:email}">${tr:Wt.Auth.email} <label class="bulma-label" for="${id:email}">${tr:Wt.Auth.email}</label>
<span class="Wt-info">${tr:Wt.Auth.email-info}</span> <div class="bulma-control bulma-has-icons-left">
</label> ${email class="bulma-input"}
${email} </div>
<p class="bulma-help is-success">${tr:Wt.Auth.email-info}</p>
</div> </div>
<div class="Wt-buttons"> <div class="bulma-field bulma-is-grouped bulma-is-grouped-centered">
${send-button} ${cancel-button} ${send-button} ${cancel-button}
</div> </div>
</div> </div>

View File

@ -84,7 +84,7 @@
<plural case="1">保持登录状态{1}周</plural> <plural case="1">保持登录状态{1}周</plural>
</message> </message>
<message id="Wt.Auth.remember-me-info.dynamic">Keeps login for {1}</message> <message id="Wt.Auth.remember-me-info.dynamic">Keeps login for {1}</message>
<message id="Wt.Auth.lost-password">Lost password</message> <message id="Wt.Auth.lost-password">忘记密码</message>
<message id="Wt.Auth.login">登录</message> <message id="Wt.Auth.login">登录</message>
<message id="Wt.Auth.logout">退出</message> <message id="Wt.Auth.logout">退出</message>
<message id="Wt.Auth.throttle-retry">{1}s后重试</message> <message id="Wt.Auth.throttle-retry">{1}s后重试</message>
@ -143,12 +143,10 @@
<!-- LostPasswordDialog --> <!-- LostPasswordDialog -->
<message id="Wt.Auth.lostpassword">Forgot your password? No sweat!</message> <message id="Wt.Auth.lostpassword">忘记密码了? 不用担心!</message>
<message id="Wt.Auth.lost-password-form-title">Recover your password</message> <message id="Wt.Auth.lost-password-form-title">重置密码</message>
<message id="Wt.Auth.lost-password-form-info">Please enter below the <message id="Wt.Auth.lost-password-form-info">请输入注册时使用的邮箱,稍后将发送一封邮件至您的邮箱以重置密码。</message>
email address which you used during registration. A mail will be <message id="Wt.Auth.send">发送</message>
sent with instructions to enter a new password.</message>
<message id="Wt.Auth.send">Send</message>
<!-- Message boxes --> <!-- Message boxes -->

View File

@ -687,13 +687,13 @@
- smtp-auth-username: the username to use for authentication (defaults to empty) - 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-auth-password: the password to use for authentication (defaults to empty)
--> -->
<!-- <property name="smtp-host">localhost</property> --> <property name="smtp-host">smtp.qq.com</property>
<!-- <property name="smtp-port">25</property> --> <property name="smtp-port">465</property>
<!-- <property name="smtp-self-host">localhost</property> --> <property name="smtp-self-host">amass.fun</property>
<!-- <property name="smtp-transport-encryption>none</property> --> <property name="smtp-transport-encryption">tls</property>
<!-- <property name="smtp-auth-method">none</property> --> <property name="smtp-auth-method">login</property>
<!-- <property name="smtp-auth-username"></property> --> <property name="smtp-auth-username">168062547@qq.com</property>
<!-- <property name="smtp-auth-password"></property> --> <property name="smtp-auth-password">your_password</property>
<!-- AuthService properties <!-- AuthService properties
@ -702,8 +702,8 @@
- auth-mail-sender-name: the sender name when AuthService sends emails, defaults to "Wt Auth module" - auth-mail-sender-name: the sender name when AuthService sends emails, defaults to "Wt Auth module"
- auth-mail-sender-address: the sender address when AuthService sends emails, defaults to "noreply-auth@www.webtoolkit.eu" - auth-mail-sender-address: the sender address when AuthService sends emails, defaults to "noreply-auth@www.webtoolkit.eu"
--> -->
<!-- <property name="auth-mail-sender-name">Wt Auth module</property> --> <property name="auth-mail-sender-name">amass</property>
<!-- <property name="auth-mail-sender-address">noreply-auth@www.webtoolkit.eu</property> --> <property name="auth-mail-sender-address">168062547@qq.com</property>
<!-- OAuthService properties <!-- OAuthService properties