소스 검색

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

version-14
Makarand Bauskar 8 년 전
committed by Rushabh Mehta
부모
커밋
ae52c7a487
1개의 변경된 파일8개의 추가작업 그리고 4개의 파일을 삭제
  1. +8
    -4
      frappe/utils/password.py

+ 8
- 4
frappe/utils/password.py 파일 보기

@@ -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


불러오는 중...
취소
저장