Always prefill username from Windows login name based on server version
authoralex-z <blackslayer4@gmail.com>
Fri, 3 Dec 2021 08:41:33 +0000 (10:41 +0200)
committeralex-z <blackslayer4@gmail.com>
Fri, 3 Dec 2021 09:08:35 +0000 (11:08 +0200)
Signed-off-by: alex-z <blackslayer4@gmail.com>
NEXTCLOUD.cmake
config.h.in
src/gui/creds/flow2auth.cpp
src/libsync/account.cpp
src/libsync/account.h
src/libsync/theme.cpp
src/libsync/theme.h

index 576ca81564cc2559e12dac3286a5f2bab87d110d..d34e682af89bbd5cbcad642856d3141718ede266 100644 (file)
@@ -13,7 +13,6 @@ set( APPLICATION_REV_DOMAIN "com.nextcloud.desktopclient" )
 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}")
index 2aebdb6b5777298a1e79afd9a03bdbd491d2c641..e9eff6c929629eef492b5647eeb3766b60e56c78 100644 (file)
@@ -31,7 +31,6 @@
 #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
 
index 9873a2705a08da0c31868237eced554cffcdbbdb..d0fbbca6ba281db3d5cac358e54af73e4beedf44 100644 (file)
@@ -133,7 +133,7 @@ void Flow2Auth::fetchNewToken(const TokenAction action)
 
         _loginUrl = loginUrl;
 
-        if (Theme::instance()->loginWithSystemUserName()) {
+        if (_account->isUsernamePrefillSupported()) {
             const auto userName = Utility::getCurrentUserName();
             if (!userName.isEmpty()) {
                 auto query = QUrlQuery(_loginUrl);
index 5242861ad8a35fb7c8b6c1a729a2f6f8421b4938..537bd71e42e5c95186d9d551c83531e1a0cc53d7 100644 (file)
@@ -57,6 +57,7 @@ using namespace QKeychain;
 
 namespace {
 constexpr int pushNotificationsReconnectInterval = 1000 * 60 * 2;
+constexpr int usernamePrefillServerVersinMinSupportedMajor = 24;
 }
 
 namespace OCC {
@@ -629,6 +630,11 @@ bool Account::serverVersionUnsupported() const
                NEXTCLOUD_SERVER_VERSION_MIN_SUPPORTED_MINOR, NEXTCLOUD_SERVER_VERSION_MIN_SUPPORTED_PATCH);
 }
 
+bool Account::isUsernamePrefillSupported() const
+{
+    return serverVersionInt() >= makeServerVersion(usernamePrefillServerVersinMinSupportedMajor, 0, 0);
+}
+
 void Account::setServerVersion(const QString &version)
 {
     if (version == _serverVersion) {
index 91cd36b1529fe4dbdfbaea949e6c360ec8859848..03e8a88ccb652ea756c8bdb178aaa170f023719e 100644 (file)
@@ -230,6 +230,8 @@ public:
      */
     bool serverVersionUnsupported() const;
 
+    bool isUsernamePrefillSupported() const;
+
     /** True when the server connection is using HTTP2  */
     bool isHttp2Supported() { return _http2Supported; }
     void setHttp2Supported(bool value) { _http2Supported = value; }
index 330b12902653634f863350808431cedea5b61dd3..ff7f58e607ff056026a8488bf8ae0c0c5af0e5a7 100644 (file)
@@ -417,15 +417,6 @@ bool Theme::forbidBadSSL() const
 #endif
 }
 
-bool Theme::loginWithSystemUserName() const
-{
-#ifdef APPLICATION_LOGIN_WITH_SYSTEM_USERNAME
-    return true;
-#else
-    return false;
-#endif
-}
-
 QString Theme::forceConfigAuthType() const
 {
     return QString();
index 6ab8fb3f70a8bf335a1f370ebd775f79a81941f0..6b9aefb255a7618d748f5cd3f8a89292499efed8 100644 (file)
@@ -254,13 +254,6 @@ public:
      */
     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".