From fe704cb3593ee99df14a50d35ec6dd827c734ce5 Mon Sep 17 00:00:00 2001 From: amass Date: Thu, 2 Jan 2025 23:02:37 +0800 Subject: [PATCH] only create cookie when not existed. --- WebApplication/Application.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/WebApplication/Application.cpp b/WebApplication/Application.cpp index bdbff8d..000a835 100644 --- a/WebApplication/Application.cpp +++ b/WebApplication/Application.cpp @@ -95,10 +95,15 @@ void Application::authEvent() { } } setInternalPath("/", true); + auto app = Amass::Singleton::instance(); auto &service = app->authService(); - Wt::Http::Cookie cookie(service.authTokenCookieName(), service.createAuthToken(u)); - setCookie(cookie); + auto &env = environment(); + auto token = env.getCookie(service.authTokenCookieName()); + if (token == nullptr) { + Wt::Http::Cookie cookie(service.authTokenCookieName(), service.createAuthToken(u)); + setCookie(cookie); + } } else { m_loginPage = m_navigationBar->removeLoginItem(); LOG(info) << "User logged out.";