@@ -96,7 +96,7 @@ bool WindowsServices::PromptCredentials(QString& user, QString& password, bool f
9696pcred.hbmBanner = nullptr ;
9797DWORD result = CredUIPromptForWindowsCredentialsW (&pcred, failed ? ERROR_LOGON_FAILURE : 0 , &pkg, packedAuth.constData (), packedAuth.size (), &authBuffer, &authSize, &save, flags);
9898packedAuth.fill (0 );
99- if (result == NO_ERROR )
99+ if (result == ERROR_SUCCESS )
100100{
101101DWORD userSize = 0 , passwordSize = 0 ;
102102CredUnPackAuthenticationBufferW (0 ,
@@ -114,8 +114,8 @@ bool WindowsServices::PromptCredentials(QString& user, QString& password, bool f
114114user.resize (userSize - 1 );
115115password.reserve (passwordSize);
116116password.resize (passwordSize - 1 );
117- Q_ASSERT (user.capacity () = = userSize);
118- Q_ASSERT (password.capacity () = = passwordSize);
117+ Q_ASSERT (user.capacity () > = userSize);
118+ Q_ASSERT (password.capacity () > = passwordSize);
119119
120120CredUnPackAuthenticationBufferW (0 ,
121121authBuffer, authSize,
@@ -149,6 +149,13 @@ bool WindowsServices::ReadCredentials(QString& user, QString& password)
149149
150150bool WindowsServices::WriteCredentials (const QString& user, const QString& password)
151151{
152+ if (user.isEmpty () && password.isEmpty ())
153+ {
154+ // Did you mean to do this?
155+ DeleteCredentials ();
156+ return true ;
157+ }
158+
152159// We're casting a bunch of const away here, but it should be safe
153160CREDENTIALW cred = {0 };
154161cred.Type = CRED_TYPE_GENERIC;
0 commit comments