diff options
author | Kevin Smith <git@kismith.co.uk> | 2011-04-26 07:29:55 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2011-04-26 07:29:55 (GMT) |
commit | 37567ebaa72cfc26e6cf49179eb988594c488c4b (patch) | |
tree | a38d5a4e919d768bf958c47e52bd313e90e441f0 /Swift/Controllers/MainController.cpp | |
parent | bc64e2e7537d714b67697cced7215ff819b0a23e (diff) | |
download | swift-contrib-37567ebaa72cfc26e6cf49179eb988594c488c4b.zip swift-contrib-37567ebaa72cfc26e6cf49179eb988594c488c4b.tar.bz2 |
Don't attempt to login without a valid node@domain JID.
Invalid JIDs and JIDs without nodes will now be rejected.
Resolves: #829
Release-Notes: Username well-formedness will now be checked before attempting to connect.
Diffstat (limited to 'Swift/Controllers/MainController.cpp')
-rw-r--r-- | Swift/Controllers/MainController.cpp | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index 2da16cc..6133ffa 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -362,19 +362,25 @@ void MainController::handleInputIdleChanged(bool idle) { } void MainController::handleLoginRequest(const std::string &username, const std::string &password, const std::string& certificateFile, bool remember, bool loginAutomatically) { - loginWindow_->setMessage(""); - loginWindow_->setIsLoggingIn(true); - profileSettings_ = new ProfileSettingsProvider(username, settings_); - profileSettings_->storeString("jid", username); - profileSettings_->storeString("certificate", certificateFile); - profileSettings_->storeString("pass", (remember || loginAutomatically) ? password : ""); - settings_->storeString("lastLoginJID", username); - settings_->storeBool("loginAutomatically", loginAutomatically); - loginWindow_->addAvailableAccount(profileSettings_->getStringSetting("jid"), profileSettings_->getStringSetting("pass"), profileSettings_->getStringSetting("certificate")); jid_ = JID(username); - password_ = password; - certificateFile_ = certificateFile; - performLoginFromCachedCredentials(); + if (!jid_.isValid() || jid_.getNode().empty()) { + loginWindow_->setMessage(QT_TRANSLATE_NOOP("", "Username not a valid format")); + loginWindow_->setIsLoggingIn(false); + } else { + loginWindow_->setMessage(""); + loginWindow_->setIsLoggingIn(true); + profileSettings_ = new ProfileSettingsProvider(username, settings_); + profileSettings_->storeString("jid", username); + profileSettings_->storeString("certificate", certificateFile); + profileSettings_->storeString("pass", (remember || loginAutomatically) ? password : ""); + settings_->storeString("lastLoginJID", username); + settings_->storeBool("loginAutomatically", loginAutomatically); + loginWindow_->addAvailableAccount(profileSettings_->getStringSetting("jid"), profileSettings_->getStringSetting("pass"), profileSettings_->getStringSetting("certificate")); + + password_ = password; + certificateFile_ = certificateFile; + performLoginFromCachedCredentials(); + } } void MainController::handlePurgeSavedLoginRequest(const std::string& username) { |