X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fcore.cpp;h=003f6dafc1225f7b14097f6f4e05578fe74ea051;hp=542d425031f9c7e591965af661e4246529505835;hb=b040ef84cdc254a0b1f083db3151f2724e45d210;hpb=2e72a5e771e0e717a4506018233fd7a27746e08f diff --git a/src/core/core.cpp b/src/core/core.cpp index 542d4250..003f6daf 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -151,11 +151,6 @@ void Core::init() { exit(0); } - if(Quassel::isOptionSet("add-user")) { - createUser(); - exit(0); - } - if(!_configured) { if(!_storageBackends.count()) { qWarning() << qPrintable(tr("Could not initialize any storage backend! Exiting...")); @@ -167,6 +162,16 @@ void Core::init() { qWarning() << "Core is currently not configured! Please connect with a Quassel Client for basic setup."; } + if(Quassel::isOptionSet("add-user")) { + createUser(); + exit(0); + } + + if(Quassel::isOptionSet("change-userpass")) { + changeUserPass(Quassel::optionValue("change-userpass")); + exit(0); + } + connect(&_server, SIGNAL(newConnection()), this, SLOT(incomingConnection())); connect(&_v6server, SIGNAL(newConnection()), this, SLOT(incomingConnection())); if(!startListening()) exit(1); // TODO make this less brutal @@ -808,6 +813,44 @@ void Core::createUser() { } } +void Core::changeUserPass(const QString &username) { + QTextStream out(stdout); + QTextStream in(stdin); + UserId userId = _storage->getUserId(username); + if(!userId.isValid()) { + out << "User " << username << " does not exist." << endl; + return; + } + + out << "Change password for user: " << username << endl; + + disableStdInEcho(); + out << "New Password: "; + out.flush(); + QString password = in.readLine().trimmed(); + out << endl; + out << "Repeat Password: "; + out.flush(); + QString password2 = in.readLine().trimmed(); + out << endl; + enableStdInEcho(); + + if(password != password2) { + qWarning() << "Passwords don't match!"; + return; + } + if(password.isEmpty()) { + qWarning() << "Password is empty!"; + return; + } + + if(_storage->updateUser(userId, password)) { + out << "Password changed successfuly!" << endl; + } else { + qWarning() << "Failed to change password!"; + } +} + AbstractSqlMigrationReader *Core::getMigrationReader(Storage *storage) { if(!storage) return 0;