mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-27 01:39:45 +00:00
[Client] Always hash input for password dialogs
Additionally, clean up repetitive code in GUIController.
This commit is contained in:
parent
3903ac6526
commit
6828d83a42
1 changed files with 27 additions and 9 deletions
|
@ -13,6 +13,8 @@
|
|||
#include <MyGUI_ScrollView.h>
|
||||
#include <MyGUI_TextIterator.h>
|
||||
|
||||
#include <extern/PicoSHA2/picosha2.h>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
#include "../mwbase/inputmanager.hpp"
|
||||
|
@ -170,15 +172,27 @@ void mwmp::GUIController::showInputBox(const BasePlayer::GUIMessageBox &guiMessa
|
|||
|
||||
void mwmp::GUIController::onInputBoxDone(MWGui::WindowBase *parWindow)
|
||||
{
|
||||
//MWBase::WindowManager *windowManager = MWBase::Environment::get().getWindowManager();
|
||||
LocalPlayer *localPlayer = Main::get().getLocalPlayer();
|
||||
std::string textInput = mInputBox->getTextInput();
|
||||
|
||||
Main::get().getLocalPlayer()->guiMessageBox.data = mInputBox->getTextInput();
|
||||
Main::get().getNetworking()->getPlayerPacket(ID_GUI_MESSAGEBOX)->setPlayer(Main::get().getLocalPlayer());
|
||||
Main::get().getNetworking()->getPlayerPacket(ID_GUI_MESSAGEBOX)->Send();
|
||||
// Send SHA256 hash of input for password dialogs after it's been hashed and rehashed,
|
||||
// for some slight extra security that doesn't require the client to keep storing a salt
|
||||
if (localPlayer->guiMessageBox.type == BasePlayer::GUIMessageBox::PasswordDialog)
|
||||
{
|
||||
textInput = picosha2::hash256_hex_string(textInput);
|
||||
textInput = picosha2::hash256_hex_string(textInput + picosha2::hash256_hex_string(picosha2::hash256_hex_string((textInput))));
|
||||
}
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(mInputBox);
|
||||
localPlayer->guiMessageBox.data = textInput;
|
||||
|
||||
PlayerPacket *playerPacket = Main::get().getNetworking()->getPlayerPacket(ID_GUI_MESSAGEBOX);
|
||||
playerPacket->setPlayer(Main::get().getLocalPlayer());
|
||||
playerPacket->Send();
|
||||
|
||||
MWBase::WindowManager *windowManager = MWBase::Environment::get().getWindowManager();
|
||||
windowManager->removeDialog(mInputBox);
|
||||
mInputBox = 0;
|
||||
MWBase::Environment::get().getWindowManager()->popGuiMode();
|
||||
windowManager->popGuiMode();
|
||||
}
|
||||
|
||||
bool mwmp::GUIController::pressedKey(int key)
|
||||
|
@ -217,9 +231,13 @@ void mwmp::GUIController::update(float dt)
|
|||
{
|
||||
LOG_MESSAGE_SIMPLE(TimedLog::LOG_VERBOSE, "Pressed: %d", pressedButton);
|
||||
calledInteractiveMessage = false;
|
||||
Main::get().getLocalPlayer()->guiMessageBox.data = MyGUI::utility::toString(pressedButton);
|
||||
Main::get().getNetworking()->getPlayerPacket(ID_GUI_MESSAGEBOX)->setPlayer(Main::get().getLocalPlayer());
|
||||
Main::get().getNetworking()->getPlayerPacket(ID_GUI_MESSAGEBOX)->Send();
|
||||
|
||||
LocalPlayer *localPlayer = Main::get().getLocalPlayer();
|
||||
localPlayer->guiMessageBox.data = MyGUI::utility::toString(pressedButton);
|
||||
|
||||
PlayerPacket *playerPacket = Main::get().getNetworking()->getPlayerPacket(ID_GUI_MESSAGEBOX);
|
||||
playerPacket->setPlayer(Main::get().getLocalPlayer());
|
||||
playerPacket->Send();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue