set( APPLICATION_VIRTUALFILE_SUFFIX "nextcloud" CACHE STRING "Virtual file suffix (not including the .)")
set( APPLICATION_OCSP_STAPLING_ENABLED OFF )
set( APPLICATION_FORBID_BAD_SSL OFF )
+set( APPLICATION_LOGIN_WITH_SYSTEM_USERNAME OFF )
set( LINUX_PACKAGE_SHORTNAME "nextcloud" )
set( LINUX_APPLICATION_ID "${APPLICATION_REV_DOMAIN}.${LINUX_PACKAGE_SHORTNAME}")
#cmakedefine APPLICATION_VIRTUALFILE_SUFFIX "@APPLICATION_VIRTUALFILE_SUFFIX@"
#cmakedefine APPLICATION_OCSP_STAPLING_ENABLED "@APPLICATION_OCSP_STAPLING_ENABLED@"
#cmakedefine APPLICATION_FORBID_BAD_SSL "@APPLICATION_FORBID_BAD_SSL@"
+#cmakedefine APPLICATION_LOGIN_WITH_SYSTEM_USERNAME "@APPLICATION_LOGIN_WITH_SYSTEM_USERNAME@"
#define APPLICATION_DOTVIRTUALFILE_SUFFIX "." APPLICATION_VIRTUALFILE_SUFFIX
#cmakedefine01 ENFORCE_VIRTUAL_FILES_SYNC_FOLDER
*/
OCSYNC_EXPORT bool isPathWindowsDrivePartitionRoot(const QString &path);
+ /**
+ * @brief Retrieves current logged-in user name from the OS
+ */
+ OCSYNC_EXPORT QString getCurrentUserName();
+
#ifdef Q_OS_WIN
OCSYNC_EXPORT bool registryKeyExists(HKEY hRootKey, const QString &subKey);
OCSYNC_EXPORT QVariant registryGetKeyValue(HKEY hRootKey, const QString &subKey, const QString &valueName);
return returnValue;
}
+QString Utility::getCurrentUserName()
+{
+ return {};
+}
+
} // namespace OCC
return true;
}
+QString Utility::getCurrentUserName()
+{
+ return {};
+}
+
} // namespace OCC
#include "utility.h"
#include <comdef.h>
+#include <Lmcons.h>
#include <shlguid.h>
#include <shlobj.h>
#include <string>
return QStringLiteral("WindowsError: %1: %2").arg(QString::number(errorCode, 16), QString::fromWCharArray(_com_error(errorCode).ErrorMessage()));
}
+QString Utility::getCurrentUserName()
+{
+ TCHAR username[UNLEN + 1] = {0};
+ DWORD len = sizeof(username) / sizeof(TCHAR);
+
+ if (!GetUserName(username, &len)) {
+ qCWarning(lcUtility) << "Could not retrieve Windows user name." << formatWinError(GetLastError());
+ }
+
+ return QString::fromWCharArray(username);
+}
Utility::NtfsPermissionLookupRAII::NtfsPermissionLookupRAII()
{
_loginUrl = loginUrl;
+
+ if (Theme::instance()->loginWithSystemUserName()) {
+ const auto userName = Utility::getCurrentUserName();
+ if (!userName.isEmpty()) {
+ auto query = QUrlQuery(_loginUrl);
+ query.addQueryItem(QStringLiteral("user"), userName);
+ _loginUrl.setQuery(query);
+ }
+ }
+
_pollToken = pollToken;
_pollEndpoint = pollEndpoint;
#endif
}
+bool Theme::loginWithSystemUserName() const
+{
+#ifdef APPLICATION_LOGIN_WITH_SYSTEM_USERNAME
+ return true;
+#else
+ return false;
+#endif
+}
+
QString Theme::forceConfigAuthType() const
{
return QString();
*/
virtual bool forbidBadSSL() const;
+ /**
+ * Use current logged in username from the system
+ *
+ * When true, the Web login form will be pre-filled with system user name
+ */
+ bool loginWithSystemUserName() const;
+
/**
* This is only usefull when previous version had a different overrideServerUrl
* with a different auth type in that case You should then specify "http" or "shibboleth".