nsILoginManager is not storing passwords
Categories
(Thunderbird :: Account Manager, defect)
Tracking
(Not tracked)
People
(Reporter: it_support, Unassigned)
Details
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.193 Safari/537.36
Steps to reproduce:
Hi,
i have a JS script (to be executed in the Error Console) that creates accounts/identities automatically. It also tries to store the password in the password manager, but this part doesn't work.
Snippet:
var hostname="mymailserver.com";
var nsILoginManager = Components.classes["@mozilla.org/login-manager;1"].getService(Components.interfaces.nsILoginManager);
var nsLoginInfo = new Components.Constructor("@mozilla.org/login-manager/loginInfo;1",Components.interfaces.nsILoginInfo,"init");
// save password
var loginInfo = new nsLoginInfo("smtp://" + hostname,null,"smtp://" + hostname,username,password,'','');
nsILoginManager.addLogin(loginInfo); // <== ineffective
Actual results:
Thunderbird keeps prompting for pwd at startup.
Expected results:
Maybe the problem is in the last 2 empty arguments to the nsLoginInfo constructor? ( should be the username and pwd form field names).
I have tried inspecting an account created by hand i already had, where the password is stored correctly.
It appears the form field names for that account are empty, so i thought they are just ignored by Thunderbird ( maybe they are important for Firefox only? )
Here is how i figured it out:
var logins = nsILoginManager.getAllLogins();
// the first element is about an existing account i have, with password stored
console.log("usernameField :"+logins[0].usernameField); // prints ""
console.log("pwd field:"+logins[0].passwordField); // prints ""
Let me know what i am missing thx!
Comment 1•5 years ago
|
||
Sorry bugzilla is not developer support forum.
Solved.
I was saving only the password for the SMTP credentials, but not for the incoming server credentials.
The solution was to add these lines:
loginInfo = new nsLoginInfo(incomingServer.localStoreType + "://" + hostname,null,incomingServer.localStoreType + "://" +
hostname,username,password,'','');
nsILoginManager.addLogin(loginInfo);
Description
•