2018-05-27 23:32:18 +01:00
|
|
|
from django.conf import settings
|
2018-03-18 15:42:51 +00:00
|
|
|
from django.core.checks import Warning, register
|
2018-05-27 14:28:41 +01:00
|
|
|
from django.db.utils import OperationalError
|
2018-03-18 15:42:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@register()
|
|
|
|
|
def changed_password_check(app_configs, **kwargs):
|
|
|
|
|
|
|
|
|
|
from documents.models import Document
|
|
|
|
|
from paperless.db import GnuPG
|
|
|
|
|
|
2018-05-27 23:32:18 +01:00
|
|
|
if not settings.PASSPHRASE:
|
|
|
|
|
return []
|
|
|
|
|
|
2018-03-18 15:42:51 +00:00
|
|
|
warning = (
|
|
|
|
|
"At least one document:\n\n {}\n\nin your data store was encrypted "
|
|
|
|
|
"with a password other than the one currently\nin use. This means "
|
|
|
|
|
"that this file, and others encrypted with the other\npassword are no "
|
|
|
|
|
"longer acessible, which is probably not what you want. If\nyou "
|
|
|
|
|
"intend to change your Paperless password, you must first export all "
|
|
|
|
|
"of\nthe old documents, start fresh with the new password and then "
|
|
|
|
|
"re-import them."
|
|
|
|
|
)
|
|
|
|
|
|
2018-05-27 14:28:41 +01:00
|
|
|
try:
|
|
|
|
|
document = Document.objects.order_by("-pk").filter(
|
|
|
|
|
storage_type=Document.STORAGE_TYPE_GPG).first()
|
|
|
|
|
if document and not GnuPG.decrypted(document.source_file):
|
|
|
|
|
return [Warning(warning.format(document))]
|
|
|
|
|
except OperationalError:
|
|
|
|
|
pass # No documents table yet
|
2018-03-18 15:42:51 +00:00
|
|
|
|
|
|
|
|
return []
|