+void Core::cacheSysident() {
+ if(isConfigured()) {
+ instance()->_authusernames = instance()->_storage->getAllAuthusernames();
+ }
+}
+
+QString Core::strictSysident(UserId user) {
+ QMap<UserId, QString> *allAuthusernames = &instance()->_authusernames;
+ auto authusername = allAuthusernames->find(user);
+ if (authusername == allAuthusernames->end()) {
+ // A new user got added since we last pulled our cache from the database.
+ // There's no way to avoid a database hit - we don't even know the authname!
+ cacheSysident();
+ authusername = allAuthusernames->find(user);
+ if (authusername == allAuthusernames->end()) {
+ // ...something very weird is going on if we ended up here (an active CoreSession without a corresponding database entry?)
+ QDebug d = qWarning();
+ d << "Unable to find authusername for UserId" << user;
+ d.nospace();
+ d << ", this should never happen!";
+ return "unknown"; // Should we just terminate the program instead?
+ }
+ }
+ return *authusername;
+}