Skip to content

Commit f0ccfa3

Browse files
committed
Logout existing sessions after a username or password change
Closes qbittorrent#18443
1 parent 0ea35c5 commit f0ccfa3

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

Diff for: src/webui/api/authcontroller.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,15 @@ AuthController::AuthController(ISessionManager *sessionManager, IApplication *ap
4545

4646
void AuthController::setUsername(const QString &username)
4747
{
48+
if (!m_username.isEmpty() && m_username != username)
49+
m_sessionManager->logoutAllSessions();
4850
m_username = username;
4951
}
5052

5153
void AuthController::setPasswordHash(const QByteArray &passwordHash)
5254
{
55+
if (!m_passwordHash.isEmpty() && m_passwordHash != passwordHash)
56+
m_sessionManager->logoutAllSessions();
5357
m_passwordHash = passwordHash;
5458
}
5559

Diff for: src/webui/api/isessionmanager.h

+1
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ struct ISessionManager
4545
virtual ISession *session() = 0;
4646
virtual void sessionStart() = 0;
4747
virtual void sessionEnd() = 0;
48+
virtual void logoutAllSessions() = 0;
4849
};

Diff for: src/webui/webapplication.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,12 @@ const Http::Environment &WebApplication::env() const
299299
return m_env;
300300
}
301301

302+
void WebApplication::logoutAllSessions()
303+
{
304+
qDeleteAll(m_sessions);
305+
m_sessions.clear();
306+
}
307+
302308
void WebApplication::setUsername(const QString &username)
303309
{
304310
m_authController->setUsername(username);

Diff for: src/webui/webapplication.h

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ class WebApplication final : public ApplicationComponent<QObject>
111111
WebSession *session() override;
112112
void sessionStart() override;
113113
void sessionEnd() override;
114+
void logoutAllSessions() override;
114115

115116
void doProcessRequest();
116117
void configure();

0 commit comments

Comments
 (0)