зеркало из https://github.com/mozilla/pjs.git
fix for bug #20401. prevent user from creating two identical
mailnews accounts. (identical means they have the same {username,hostname,type}.) r=mscott
This commit is contained in:
Родитель
c10b9ecb82
Коммит
1430ebc7c6
|
@ -222,7 +222,6 @@ function AccountDataToPageData(accountData, pageData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// take data from each page of pageData and dump it into accountData
|
// take data from each page of pageData and dump it into accountData
|
||||||
// use: to put results of wizard into a account-oriented object
|
// use: to put results of wizard into a account-oriented object
|
||||||
function PageDataToAccountData(pageData, accountData)
|
function PageDataToAccountData(pageData, accountData)
|
||||||
|
@ -566,6 +565,28 @@ function serverIsNntp(pageData) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getUsernameFromEmail(email)
|
||||||
|
{
|
||||||
|
var emailData = email.split("@");
|
||||||
|
return emailData[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCurrentUserName(pageData)
|
||||||
|
{
|
||||||
|
var userName = "";
|
||||||
|
|
||||||
|
if (pageData.login) {
|
||||||
|
if (pageData.login.username) {
|
||||||
|
userName = pageData.login.username.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (userName == "") {
|
||||||
|
var email = pageData.identity.email.value;
|
||||||
|
userName = getUsernameFromEmail(email);
|
||||||
|
}
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
|
||||||
function getCurrentServerType(pageData) {
|
function getCurrentServerType(pageData) {
|
||||||
var servertype = "pop3"; // hopefully don't resort to default!
|
var servertype = "pop3"; // hopefully don't resort to default!
|
||||||
if (serverIsNntp(pageData))
|
if (serverIsNntp(pageData))
|
||||||
|
@ -642,7 +663,6 @@ function PrefillAccountForIsp(ispName)
|
||||||
AccountDataToPageData(ispData, pageData);
|
AccountDataToPageData(ispData, pageData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// does any cleanup work for the the account data
|
// does any cleanup work for the the account data
|
||||||
// - sets the username from the email address if it's not already set
|
// - sets the username from the email address if it's not already set
|
||||||
// - anything else?
|
// - anything else?
|
||||||
|
@ -652,8 +672,7 @@ function FixupAccountDataForIsp(accountData)
|
||||||
var username;
|
var username;
|
||||||
|
|
||||||
if (email) {
|
if (email) {
|
||||||
var emailData = email.split("@");
|
username = getUsernameFromEmail(email);
|
||||||
username = emailData[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// fix up the username
|
// fix up the username
|
||||||
|
|
|
@ -34,6 +34,30 @@ function validate() {
|
||||||
window.alert(alertText);
|
window.alert(alertText);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dump("check if this account exists\n");
|
||||||
|
var pageData = parent.GetPageData();
|
||||||
|
var hostName = servername.value;
|
||||||
|
var serverType = parent.getCurrentServerType(pageData);
|
||||||
|
var userName = parent.getCurrentUserName(pageData);
|
||||||
|
|
||||||
|
var accountExists = false;
|
||||||
|
var accountManager = Components.classes["component://netscape/messenger/account-manager"].getService(Components.interfaces.nsIMsgAccountManager);
|
||||||
|
try {
|
||||||
|
var server = accountManager.FindServer(userName,hostName,serverType);
|
||||||
|
if (server) {
|
||||||
|
accountExists = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (ex) {
|
||||||
|
accountExists = false;
|
||||||
|
}
|
||||||
|
if (accountExists) {
|
||||||
|
var alertText = Bundle.GetStringFromName("accountExists");
|
||||||
|
window.alert(alertText);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ enterAccountName=Please enter a name for this account.
|
||||||
enterUserName=Please enter a username.
|
enterUserName=Please enter a username.
|
||||||
enterName=Please enter your name.
|
enterName=Please enter your name.
|
||||||
enterValidEmail=Please enter a valid email address.
|
enterValidEmail=Please enter a valid email address.
|
||||||
|
accountExists=An account of this type with the same username and hostname already exists. Go back and change it or hit cancel.
|
||||||
|
|
||||||
# when the wizard already has a domain (Should we say something different?)
|
# when the wizard already has a domain (Should we say something different?)
|
||||||
enterValidEmailPrefix=Please enter a valid email address.
|
enterValidEmailPrefix=Please enter a valid email address.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче