fix: allow guests/users without desk access to upload text files (#16920)

* fix: allow guests/users without desk access to upload text files

* chore: update error message

Co-authored-by: Shariq Ansari <30859809+shariquerik@users.noreply.github.com>
This commit is contained in:
Ritwik Puri 2022-05-18 17:39:44 +05:30 committed by GitHub
parent 176518ed2c
commit 20d73cae24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,6 +25,7 @@ ALLOWED_MIMETYPES = (
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"application/vnd.oasis.opendocument.text",
"application/vnd.oasis.opendocument.spreadsheet",
"text/plain",
)
@ -202,7 +203,7 @@ def upload_file():
if not file_url and (frappe.session.user == "Guest" or (user and not user.has_desk_access())):
filetype = guess_type(filename)[0]
if filetype not in ALLOWED_MIMETYPES:
frappe.throw(_("You can only upload JPG, PNG, PDF, or Microsoft documents."))
frappe.throw(_("You can only upload JPG, PNG, PDF, TXT or Microsoft documents."))
if method:
method = frappe.get_attr(method)