mirror of https://gitlab.com/bashrc2/epicyon
Support memorial accounts
parent
7c29ec3f98
commit
761a326bc8
5
auth.py
5
auth.py
|
@ -14,6 +14,7 @@ import os
|
||||||
import secrets
|
import secrets
|
||||||
import datetime
|
import datetime
|
||||||
from utils import is_system_account
|
from utils import is_system_account
|
||||||
|
from utils import is_memorial_account
|
||||||
from utils import has_users_path
|
from utils import has_users_path
|
||||||
from utils import text_in_file
|
from utils import text_in_file
|
||||||
from utils import remove_eol
|
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 (' +
|
') does not match the one in the Authorization header (' +
|
||||||
nickname + ')')
|
nickname + ')')
|
||||||
return False
|
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'
|
password_file = base_dir + '/accounts/passwords'
|
||||||
if not os.path.isfile(password_file):
|
if not os.path.isfile(password_file):
|
||||||
if debug:
|
if debug:
|
||||||
|
|
10
daemon.py
10
daemon.py
|
@ -296,6 +296,7 @@ from languages import set_actor_languages
|
||||||
from languages import get_understood_languages
|
from languages import get_understood_languages
|
||||||
from like import update_likes_collection
|
from like import update_likes_collection
|
||||||
from reaction import update_reaction_collection
|
from reaction import update_reaction_collection
|
||||||
|
from utils import is_memorial_account
|
||||||
from utils import is_public_post_from_url
|
from utils import is_public_post_from_url
|
||||||
from utils import license_link_from_name
|
from utils import license_link_from_name
|
||||||
from utils import acct_handle_dir
|
from utils import acct_handle_dir
|
||||||
|
@ -8305,6 +8306,15 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'unable to delete ' +
|
'unable to delete ' +
|
||||||
git_projects_filename)
|
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
|
# save actor json file within accounts
|
||||||
if actor_changed:
|
if actor_changed:
|
||||||
add_name_emojis_to_tags(base_dir, http_prefix,
|
add_name_emojis_to_tags(base_dir, http_prefix,
|
||||||
|
|
11
utils.py
11
utils.py
|
@ -741,6 +741,17 @@ def is_system_account(nickname: str) -> bool:
|
||||||
return False
|
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:
|
def _create_config(base_dir: str) -> None:
|
||||||
"""Creates a configuration file
|
"""Creates a configuration file
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue