Ver a proveniência

[minor] added error message if the encryption_key in the site_config is changed (#3326)

version-14
Makarand Bauskar há 8 anos
committed by Rushabh Mehta
ascendente
cometimento
ae52c7a487
1 ficheiros alterados com 8 adições e 4 eliminações
  1. +8
    -4
      frappe/utils/password.py

+ 8
- 4
frappe/utils/password.py Ver ficheiro

@@ -5,7 +5,7 @@ from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.utils import cstr, encode
from cryptography.fernet import Fernet
from cryptography.fernet import Fernet, InvalidToken

def get_decrypted_password(doctype, name, fieldname='password', raise_exception=True):
auth = frappe.db.sql('''select `password` from `__Auth`
@@ -97,9 +97,13 @@ def encrypt(pwd):
return cipher_text

def decrypt(pwd):
cipher_suite = Fernet(encode(get_encryption_key()))
plain_text = cstr(cipher_suite.decrypt(encode(pwd)))
return plain_text
try:
cipher_suite = Fernet(encode(get_encryption_key()))
plain_text = cstr(cipher_suite.decrypt(encode(pwd)))
return plain_text
except InvalidToken:
# encryption_key in site_config is changed and not valid
frappe.throw(_('Encryption key is invalid, Please check site_config.json'))

def get_encryption_key():
from frappe.installer import update_site_config


Carregando…
Cancelar
Guardar