diff --git a/auth.py b/auth.py index 33f9b38d7..e593c26af 100644 --- a/auth.py +++ b/auth.py @@ -14,6 +14,7 @@ import os import secrets import datetime from utils import is_system_account +from utils import is_memorial_account from utils import has_users_path from utils import text_in_file from utils import remove_eol @@ -138,6 +139,10 @@ def authorize_basic(base_dir: str, path: str, auth_header: str, ') does not match the one in the Authorization header (' + nickname + ')') return False + if is_memorial_account(base_dir, nickname): + print('basic auth - attempted login using memorial account ' + + nickname + ' in Auth header') + return False password_file = base_dir + '/accounts/passwords' if not os.path.isfile(password_file): if debug: diff --git a/daemon.py b/daemon.py index a22c6522a..1bae8700d 100644 --- a/daemon.py +++ b/daemon.py @@ -296,6 +296,7 @@ from languages import set_actor_languages from languages import get_understood_languages from like import update_likes_collection from reaction import update_reaction_collection +from utils import is_memorial_account from utils import is_public_post_from_url from utils import license_link_from_name from utils import acct_handle_dir @@ -8305,6 +8306,15 @@ class PubServer(BaseHTTPRequestHandler): 'unable to delete ' + git_projects_filename) + # change memorial status + if is_memorial_account(base_dir, nickname): + if not actor_json.get('memorial'): + actor_json['memorial'] = True + actor_changed = True + elif actor_json.get('memorial'): + actor_json['memorial'] = False + actor_changed = True + # save actor json file within accounts if actor_changed: add_name_emojis_to_tags(base_dir, http_prefix, diff --git a/utils.py b/utils.py index eae416c19..3427421d6 100644 --- a/utils.py +++ b/utils.py @@ -741,6 +741,17 @@ def is_system_account(nickname: str) -> bool: return False +def is_memorial_account(base_dir: str, nickname: str) -> bool: + """Returns true if the given nickname is a memorial account + """ + memorial_file = base_dir + '/accounts/memorial' + if not os.path.isfile(memorial_file): + return False + if text_in_file(nickname + '\n', memorial_file, True): + return True + return False + + def _create_config(base_dir: str) -> None: """Creates a configuration file """