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
DatabaseTest.cpp
MailTest.cpp
)
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));
if (!embedded) {
m_navigationBar = root()->addNew<NavigationBar>();
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<Wt::Auth::AuthService>();
m_authService->setEmailVerificationEnabled(true);
m_authService->setEmailVerificationRequired(true);
m_authService->setAuthTokensEnabled(true, "logincookie");
m_passwordService = std::make_unique<Wt::Auth::PasswordService>(*m_authService);

View File

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

View File

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

View File

@ -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)
-->
<!-- <property name="smtp-host">localhost</property> -->
<!-- <property name="smtp-port">25</property> -->
<!-- <property name="smtp-self-host">localhost</property> -->
<!-- <property name="smtp-transport-encryption>none</property> -->
<!-- <property name="smtp-auth-method">none</property> -->
<!-- <property name="smtp-auth-username"></property> -->
<!-- <property name="smtp-auth-password"></property> -->
<property name="smtp-host">smtp.qq.com</property>
<property name="smtp-port">465</property>
<property name="smtp-self-host">amass.fun</property>
<property name="smtp-transport-encryption">tls</property>
<property name="smtp-auth-method">login</property>
<property name="smtp-auth-username">168062547@qq.com</property>
<property name="smtp-auth-password">your_password</property>
<!-- 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-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-address">noreply-auth@www.webtoolkit.eu</property> -->
<property name="auth-mail-sender-name">amass</property>
<property name="auth-mail-sender-address">168062547@qq.com</property>
<!-- OAuthService properties