Last active
August 29, 2015 13:56
-
-
Save Noitidart/9300413 to your computer and use it in GitHub Desktop.
_ff-addon-snippet-MasterPasswordPrompt - This snippet checks to see if master password exists. If it does it prompts user to enter it and if they get it right returns true else fail. If no master password exists then returns true.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var me = Services.wm.getMostRecentWindow(null); | |
| var tokenDB = Cc['@mozilla.org/security/pk11tokendb;1'].getService(Ci.nsIPK11TokenDB); | |
| var master_password = tokenDB.getInternalKeyToken(); | |
| var master_password_authenticated; | |
| try { | |
| master_password_authenticated = Components.isSuccessCode(token.login(false)); //login argument is false meaning that if the user had previously entered their master password it will not prompt them now AND if they had not entered it before and it is still valid for the session it will NOT prompt. IF you set it to true then regardless if the user entered it in before or not it will force them to enter it again | |
| } catch (ex) { | |
| master_password_authenticated = false; | |
| } | |
| me.alert('master passsword pass? = ' + master_password_authenticated); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
README
Rev1
Done with master pw intact
Rev2
Done with master pw intact.
Tested when there is no master pw and it passes fine. If there is no master pw then if force is false or true it doesnt matter it always returns successfully.
Using login function seen at MXR - nsIPK11Token.idl and MXR - nsPK11TokenDB.cpp