Page Menu
Home
Wildfire Games
Search
Configure Global Search
Log In
Paste
P288
Allow Changing Lobby User Password
Active
Public
Actions
Authored by
lyv
on Oct 25 2022, 5:39 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Tags
None
Referenced Files
F3068241: Allow Changing Lobby User Password
Oct 25 2022, 5:39 PM
2022-10-25 17:39:06 (UTC+2)
Subscribers
defc0n
Dunedan
diff --git a/source/lobby/IXmppClient.h b/source/lobby/IXmppClient.h
index fb241aff48..f275b34de0 100644
--- a/source/lobby/IXmppClient.h
+++ b/source/lobby/IXmppClient.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2021 Wildfire Games.
+/* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -43,6 +43,7 @@ public:
virtual void SetNick(const std::string& nick) = 0;
virtual std::string GetNick() const = 0;
virtual std::string GetJID() const = 0;
+ virtual void ChangePassword(const std::string& newPassword) = 0;
virtual void kick(const std::string& nick, const std::string& reason) = 0;
virtual void ban(const std::string& nick, const std::string& reason) = 0;
virtual void SetPresence(const std::string& presence) = 0;
diff --git a/source/lobby/XmppClient.cpp b/source/lobby/XmppClient.cpp
index e1279c2dec..6571d616ad 100644
--- a/source/lobby/XmppClient.cpp
+++ b/source/lobby/XmppClient.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 2021 Wildfire Games.
+/* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -81,6 +81,7 @@ XmppClient::XmppClient(const ScriptInterface* scriptInterface, const std::string
m_client(nullptr),
m_mucRoom(nullptr),
m_registration(nullptr),
+ m_regOpt(regOpt),
m_username(sUsername),
m_password(sPassword),
m_room(sRoom),
@@ -151,6 +152,9 @@ XmppClient::XmppClient(const ScriptInterface* scriptInterface, const std::string
m_client->registerMessageHandler(this);
+ m_registration = new glooxwrapper::Registration(m_client);
+ m_registration->registerRegistrationHandler(this);
+
// Uncomment to see the raw stanzas
//m_client->getWrapped()->logInstance().registerLogHandler( gloox::LogLevelDebug, gloox::LogAreaAll, this );
@@ -161,12 +165,6 @@ XmppClient::XmppClient(const ScriptInterface* scriptInterface, const std::string
// Get room history.
m_mucRoom->setRequestHistory(historyRequestSize, gloox::MUCRoom::HistoryMaxStanzas);
}
- else
- {
- // Registration
- m_registration = new glooxwrapper::Registration(m_client);
- m_registration->registerRegistrationHandler(this);
- }
m_sessionManager = new glooxwrapper::SessionManager(m_client, this);
// Register plugins to allow gloox parse them in incoming sessions
@@ -254,7 +252,7 @@ void XmppClient::onConnect()
m_mucRoom->join();
}
- if (m_registration)
+ if (m_regOpt)
m_registration->fetchRegistrationFields();
}
@@ -1193,6 +1191,17 @@ std::string XmppClient::GetJID() const
return m_client->getJID().to_string();
}
+/**
+ * Change password for authenticated user.
+ *
+ * @param newPassword New password
+ */
+void XmppClient::ChangePassword(const std::string& newPassword)
+{
+ if (!newPassword.empty())
+ m_registration->changePassword(m_username, newPassword);
+}
+
/**
* Kick a player from the current room.
*
diff --git a/source/lobby/XmppClient.h b/source/lobby/XmppClient.h
index 31dfe478f1..c5c90e9b65 100644
--- a/source/lobby/XmppClient.h
+++ b/source/lobby/XmppClient.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2021 Wildfire Games.
+/* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -63,6 +63,7 @@ private:
gloox::CertStatus m_certStatus;
bool m_initialLoadComplete;
bool m_isConnected;
+ bool m_regOpt;
public:
// Basic
@@ -93,6 +94,7 @@ public:
void SetNick(const std::string& nick);
std::string GetNick() const;
std::string GetJID() const;
+ void ChangePassword(const std::string& newPassword);
void kick(const std::string& nick, const std::string& reason);
void ban(const std::string& nick, const std::string& reason);
void SetPresence(const std::string& presence);
diff --git a/source/lobby/glooxwrapper/glooxwrapper.cpp b/source/lobby/glooxwrapper/glooxwrapper.cpp
index f7ad6e74d3..bdee3ed8b9 100644
--- a/source/lobby/glooxwrapper/glooxwrapper.cpp
+++ b/source/lobby/glooxwrapper/glooxwrapper.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 2021 Wildfire Games.
+/* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -697,6 +697,11 @@ bool glooxwrapper::Registration::createAccount(int fields, const glooxwrapper::R
return m_Wrapped->createAccount(fields, valuesUnwrapped);
}
+void glooxwrapper::Registration::changePassword(const string& username, const string& password)
+{
+ m_Wrapped->changePassword(username.to_string(), password.to_string());
+}
+
void glooxwrapper::Registration::registerRegistrationHandler(RegistrationHandler* rh)
{
gloox::RegistrationHandler* handler = new RegistrationHandlerWrapper(rh);
diff --git a/source/lobby/glooxwrapper/glooxwrapper.h b/source/lobby/glooxwrapper/glooxwrapper.h
index 0e03e1d656..bd464d55ac 100644
--- a/source/lobby/glooxwrapper/glooxwrapper.h
+++ b/source/lobby/glooxwrapper/glooxwrapper.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2021 Wildfire Games.
+/* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -571,6 +571,7 @@ namespace glooxwrapper
~Registration();
void fetchRegistrationFields();
bool createAccount(int fields, const RegistrationFields& values);
+ void changePassword(const string& username, const string& password);
void registerRegistrationHandler(RegistrationHandler* rh);
};
diff --git a/source/lobby/scripting/JSInterface_Lobby.cpp b/source/lobby/scripting/JSInterface_Lobby.cpp
index bc29625d9c..bce6c2ff71 100644
--- a/source/lobby/scripting/JSInterface_Lobby.cpp
+++ b/source/lobby/scripting/JSInterface_Lobby.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 2021 Wildfire Games.
+/* Copyright (C) 2022 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -218,6 +218,7 @@ void RegisterScriptFunctions(const ScriptRequest& rq)
REGISTER_XMPP(SetNick, "LobbySetNick");
REGISTER_XMPP(GetNick, "LobbyGetNick");
REGISTER_XMPP(GetJID, "LobbyGetJID");
+ REGISTER_XMPP(ChangePassword, "LobbyChangePassword");
REGISTER_XMPP(kick, "LobbyKick");
REGISTER_XMPP(ban, "LobbyBan");
REGISTER_XMPP(GetPresence, "LobbyGetPlayerPresence");
Event Timeline
lyv
created this paste.
Oct 25 2022, 5:39 PM
2022-10-25 17:39:06 (UTC+2)
lyv
changed the visibility from "All Users" to "Public (No Login Required)".
Nov 20 2022, 1:50 PM
2022-11-20 13:50:11 (UTC+1)
wraitii
mentioned this in
D5039: Allow changing lobby password inside 0 A.D.
.
Jun 7 2023, 1:33 PM
2023-06-07 13:33:32 (UTC+2)
Log In to Comment