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..."));
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
setupCoreForInternalUsage();
}
- UserId uid = _storage->internalUser();
+ UserId uid;
+ if(_storage) {
+ uid = _storage->internalUser();
+ } else {
+ qWarning() << "Core::setupInternalClientSession(): You're trying to run monolithic Quassel with an unusable Backend! Go fix it!";
+ return;
+ }
// Find or create session for validated user
SessionThread *sess;
}
}
+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;