trilium/change-password.py

28 lines
803 B
Python
Raw Normal View History

2017-09-10 01:53:58 +08:00
#!/usr/bin/python
import getpass
import src.my_scrypt
2017-09-13 10:09:09 +08:00
import src.sql
import src.change_password
2017-09-10 01:53:58 +08:00
config = src.config_provider.getConfig()
src.sql.connect(config['Document']['documentPath'])
2017-09-13 10:09:09 +08:00
current_password = getpass.getpass(prompt="Enter current password: ")
2017-09-10 01:53:58 +08:00
2017-09-13 10:09:09 +08:00
new_password1 = getpass.getpass(prompt="Enter new password: ")
new_password2 = getpass.getpass(prompt="Repeat the same password: ")
2017-09-10 01:53:58 +08:00
2017-09-13 10:09:09 +08:00
if new_password1 != new_password2:
2017-09-10 01:53:58 +08:00
print('Entered passwords are not identical!')
exit(-1)
2017-09-13 10:09:09 +08:00
ret = src.change_password.change_password(current_password, new_password1)
2017-09-10 01:53:58 +08:00
2017-09-13 10:09:09 +08:00
if (ret['success']):
print("Changes committed. All encrypted notes were re-encrypted successfully with new password key.")
print("You can now start application and login with new password.")
else:
print(ret['message'])