*** Wartungsfenster jeden ersten Mittwoch vormittag im Monat ***

Skip to content
Snippets Groups Projects
Commit b310934d authored by Moser, Maximilian's avatar Moser, Maximilian
Browse files

Remove old 'trusted-publisher' role

* this hasn't been used ever since we switched over to curation reviews
parent d71dd265
Branches
Tags
1 merge request!59Clean up old cruft
...@@ -45,30 +45,16 @@ def _get_or_create_role(role_name, description): ...@@ -45,30 +45,16 @@ def _get_or_create_role(role_name, description):
def auto_trust_user(user): def auto_trust_user(user):
"""Automatically trust newly registered users if that's configured.""" """Automatically trust newly registered users if that's configured."""
auto_trust_enabled = current_app.config.get("CONFIG_TUW_AUTO_TRUST_USERS") auto_trust_enabled = current_app.config.get("CONFIG_TUW_AUTO_TRUST_USERS")
auto_allow_publish_enabled = current_app.config.get("CONFIG_TUW_AUTO_ALLOW_PUBLISH")
trust_check = current_app.config.get("CONFIG_TUW_AUTO_TRUST_CONDITION", None) trust_check = current_app.config.get("CONFIG_TUW_AUTO_TRUST_CONDITION", None)
allow_publish_check = current_app.config.get(
"CONFIG_TUW_AUTO_ALLOW_PUBLISH_CONDITION", None
)
if user and auto_trust_enabled: if user and auto_trust_enabled:
# if the user was created successfully and auto-trust is enabled... # if the user was created successfully and auto-trust is enabled...
trusted_user = _get_or_create_role( trusted_user = _get_or_create_role(
"trusted-user", "Users trusted with extra permissions" "trusted-user", "Users trusted with upload permissions"
)
trusted_publisher = _get_or_create_role(
"trusted-publisher", "Users trusted with publication rights"
) )
# if no trust condition is specified, trust the user # if no trust condition is specified, trust the user
if trust_check is None or trust_check(user): if trust_check is None or trust_check(user):
# NOTE: the add_role_to_user function is idempotent # NOTE: the add_role_to_user function is idempotent
current_datastore.add_role_to_user(user, trusted_user) current_datastore.add_role_to_user(user, trusted_user)
# perform similar checks for auto-allow-publish
if auto_allow_publish_enabled and (
allow_publish_check is None or allow_publish_check(user)
):
current_datastore.add_role_to_user(user, trusted_publisher)
db.session.commit() db.session.commit()
...@@ -37,15 +37,6 @@ This must be a function that accepts a 'user' argument and returns a boolean val ...@@ -37,15 +37,6 @@ This must be a function that accepts a 'user' argument and returns a boolean val
Alternatively, it can be set to None. This is the same as ``lambda u: True``. Alternatively, it can be set to None. This is the same as ``lambda u: True``.
""" """
CONFIG_TUW_AUTO_ALLOW_PUBLISH = True
"""Whether or not to auto-assign the 'trusted-publisher' role to new users.
Note: This setting will only come into play if AUTO_TURST_USERS is enabled.
"""
CONFIG_TUW_AUTO_ALLOW_PUBLISH_CONDITION = check_user_email_for_tuwien
"""Similar to AUTO_TRUST_CONDITION, but for the 'trusted-publisher' role."""
CONFIG_TUW_READ_ONLY_MODE = False CONFIG_TUW_READ_ONLY_MODE = False
"""Disallow insert and update operations in the repository.""" """Disallow insert and update operations in the repository."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment