зеркало из https://github.com/mozilla/pjs.git
fix 249240 reprompt for password when logon fails, with previous password filled in, sr=mscott
This commit is contained in:
Родитель
f2666dc0d3
Коммит
a3749c28d3
|
@ -2697,10 +2697,9 @@ SINGSIGN_PromptPassword
|
|||
/* get previous password used with this username, pick first user if no username found */
|
||||
si_RestoreOldSignonDataFromBrowser(dialog, passwordRealm, username.IsEmpty(), username, password);
|
||||
|
||||
*pwd = ToNewUnicode(password);
|
||||
|
||||
/* return if a password was found */
|
||||
if (!password.IsEmpty()) {
|
||||
*pwd = ToNewUnicode(password);
|
||||
*pressedOK = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -875,18 +875,22 @@ nsMsgIncomingServer::GetPasswordWithUI(const PRUnichar * aPromptMessage, const
|
|||
}
|
||||
if (dialog)
|
||||
{
|
||||
nsXPIDLString uniPassword;
|
||||
nsXPIDLCString serverUri;
|
||||
rv = GetServerURI(getter_Copies(serverUri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
PRBool passwordProtectLocalCache = PR_FALSE;
|
||||
|
||||
(void) m_prefBranch->GetBoolPref( "mail.password_protect_local_cache", &passwordProtectLocalCache);
|
||||
PRUnichar *uniPassword = nsnull;
|
||||
if (*aPassword)
|
||||
uniPassword = ToNewUnicode(NS_ConvertASCIItoUTF16(*aPassword));
|
||||
|
||||
PRUint32 savePasswordType = (passwordProtectLocalCache) ? nsIAuthPrompt::SAVE_PASSWORD_FOR_SESSION : nsIAuthPrompt::SAVE_PASSWORD_PERMANENTLY;
|
||||
rv = dialog->PromptPassword(aPromptTitle, aPromptMessage,
|
||||
NS_ConvertASCIItoUTF16(serverUri).get(), savePasswordType,
|
||||
getter_Copies(uniPassword), okayValue);
|
||||
&uniPassword, okayValue);
|
||||
nsAutoString uniPasswordAdopted;
|
||||
uniPasswordAdopted.Adopt(uniPassword);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!*okayValue) // if the user pressed cancel, just return NULL;
|
||||
|
@ -896,8 +900,8 @@ nsMsgIncomingServer::GetPasswordWithUI(const PRUnichar * aPromptMessage, const
|
|||
}
|
||||
|
||||
// we got a password back...so remember it
|
||||
nsCString aCStr; aCStr.AssignWithConversion(uniPassword);
|
||||
|
||||
nsCString aCStr;
|
||||
aCStr.AssignWithConversion(uniPasswordAdopted);
|
||||
rv = SetPassword(aCStr.get());
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
} // if we got a prompt dialog
|
||||
|
|
|
@ -182,6 +182,8 @@ protected:
|
|||
nsCOMPtr<nsISupports> mOwner;
|
||||
nsCString m_ContentType;
|
||||
|
||||
nsCString m_lastPasswordSent; // used to prefill the password prompt
|
||||
|
||||
// private helper routine used by subclasses to quickly get a reference to the correct prompt dialog
|
||||
// for a mailnews url.
|
||||
nsresult GetPromptDialogFromUrl(nsIMsgMailNewsUrl * aMsgUrl, nsIPrompt ** aPromptDialog);
|
||||
|
|
|
@ -7597,12 +7597,17 @@ PRBool nsImapProtocol::TryToLogon()
|
|||
rv = GetMsgWindow(getter_AddRefs(aMsgWindow));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
rv = m_imapServerSink->PromptForPassword(getter_Copies(password), aMsgWindow);
|
||||
char *pPassword = ToNewCString(m_lastPasswordSent);
|
||||
char *savePassword = pPassword;
|
||||
rv = m_imapServerSink->PromptForPassword(&pPassword, aMsgWindow);
|
||||
PR_Free(savePassword);
|
||||
if (rv == NS_MSG_PASSWORD_PROMPT_CANCELLED)
|
||||
break;
|
||||
password.Adopt(pPassword);
|
||||
}
|
||||
|
||||
clientSucceeded = PR_TRUE;
|
||||
m_lastPasswordSent = password;
|
||||
// Use CRAM/NTLM/MSN only if secure auth is enabled. This is for servers that
|
||||
// say they support CRAM but are so badly broken that trying it causes
|
||||
// all subsequent login attempts to fail (bug 231303, bug 227560)
|
||||
|
|
|
@ -692,6 +692,12 @@ nsresult nsPop3Protocol::GetPassword(char ** aPassword, PRBool *okayValue)
|
|||
PRBool isAuthenticated;
|
||||
m_nsIPop3Sink->GetUserAuthenticated(&isAuthenticated);
|
||||
|
||||
// pass the failed password into the password prompt so that
|
||||
// it will be pre-filled, in case it failed because of a
|
||||
// server problem and not because it was wrong.
|
||||
if (!m_lastPasswordSent.IsEmpty())
|
||||
*aPassword = ToNewCString(m_lastPasswordSent);
|
||||
|
||||
// clear the password if the last one failed
|
||||
if (TestFlag(POP3_PASSWORD_FAILED))
|
||||
{
|
||||
|
@ -714,8 +720,7 @@ nsresult nsPop3Protocol::GetPassword(char ** aPassword, PRBool *okayValue)
|
|||
// if we haven't successfully logged onto the server in this session
|
||||
// and tried at least twice or if the server threw the specific error,
|
||||
// forget the password.
|
||||
if ((!isAuthenticated && m_pop3ConData->logonFailureCount > 1) ||
|
||||
TestFlag(POP3_AUTH_FAILURE))
|
||||
if ((!isAuthenticated || m_pop3ConData->logonFailureCount > 2))
|
||||
rv = server->ForgetPassword();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
mStringService->GetStringByID(POP3_PREVIOUSLY_ENTERED_PASSWORD_IS_INVALID_ETC, getter_Copies(passwordTemplate));
|
||||
|
@ -738,9 +743,9 @@ nsresult nsPop3Protocol::GetPassword(char ** aPassword, PRBool *okayValue)
|
|||
rv = server->GetPasswordWithUI(passwordPromptString, passwordTitle.get(),
|
||||
aMsgWindow, okayValue, aPassword);
|
||||
nsTextFormatter::smprintf_free(passwordPromptString);
|
||||
ClearFlag(POP3_PASSWORD_FAILED|POP3_AUTH_FAILURE);
|
||||
}
|
||||
|
||||
ClearFlag(POP3_PASSWORD_FAILED|POP3_AUTH_FAILURE);
|
||||
if (NS_FAILED(rv))
|
||||
m_pop3ConData->next_state = POP3_ERROR_DONE;
|
||||
} // if we have a server
|
||||
|
@ -1458,7 +1463,7 @@ PRInt32 nsPop3Protocol::AuthFallback()
|
|||
if(m_password_already_sent)
|
||||
{
|
||||
m_nsIPop3Sink->SetUserAuthenticated(PR_TRUE);
|
||||
|
||||
ClearFlag(POP3_PASSWORD_FAILED);
|
||||
m_pop3ConData->next_state = (m_pop3ConData->get_url)
|
||||
? POP3_SEND_GURL : POP3_SEND_STAT;
|
||||
}
|
||||
|
@ -1487,6 +1492,7 @@ PRInt32 nsPop3Protocol::AuthFallback()
|
|||
Error((m_password_already_sent)
|
||||
? POP3_PASSWORD_FAILURE : POP3_USERNAME_FAILURE);
|
||||
SetFlag(POP3_PASSWORD_FAILED);
|
||||
ClearFlag(POP3_AUTH_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1903,7 +1909,7 @@ PRInt32 nsPop3Protocol::SendPassword()
|
|||
m_pop3ConData->pause_for_read = PR_TRUE;
|
||||
|
||||
m_password_already_sent = PR_TRUE;
|
||||
|
||||
m_lastPasswordSent = password;
|
||||
return SendData(m_url, cmd.get(), PR_TRUE);
|
||||
}
|
||||
|
||||
|
@ -3919,7 +3925,7 @@ nsresult nsPop3Protocol::ProcessProtocolState(nsIURI * url, nsIInputStream * aIn
|
|||
nsCRT::free(statusTemplate);
|
||||
}
|
||||
|
||||
PR_ASSERT (!TestFlag(POP3_PASSWORD_FAILED));
|
||||
NS_ASSERTION (!TestFlag(POP3_PASSWORD_FAILED), "POP3_PASSWORD_FAILED set when del_started");
|
||||
m_nsIPop3Sink->AbortMailDelivery(this);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче