diff --git a/config.yaml.dist b/config.yaml.dist index a53009c3..42267452 100644 --- a/config.yaml.dist +++ b/config.yaml.dist @@ -51,8 +51,6 @@ enable_safety: yes tag_name_regex: ^\S+$ tag_category_name_regex: ^[^\s%+#/]+$ -# Disable registration by setting false -registration_enabled: true # don't make these more restrictive unless you want to annoy people; if you do # customize them, make sure to update the instructions in the registration form diff --git a/server/szurubooru/api/user_api.py b/server/szurubooru/api/user_api.py index 782a9e95..e456f22e 100644 --- a/server/szurubooru/api/user_api.py +++ b/server/szurubooru/api/user_api.py @@ -1,5 +1,5 @@ from typing import Any, Dict -from szurubooru import model, search, rest, config, errors +from szurubooru import model, search, rest from szurubooru.func import auth, users, serialization, versions @@ -26,24 +26,21 @@ def get_users( @rest.routes.post('/users/?') def create_user( ctx: rest.Context, _params: Dict[str, str] = {}) -> rest.Response: - if config.config['registration_enabled']: - auth.verify_privilege(ctx.user, 'users:create') - name = ctx.get_param_as_string('name') - password = ctx.get_param_as_string('password') - email = ctx.get_param_as_string('email', default='') - user = users.create_user(name, password, email) - if ctx.has_param('rank'): - users.update_user_rank(user, ctx.get_param_as_string('rank'), ctx.user) - if ctx.has_param('avatarStyle'): - users.update_user_avatar( - user, - ctx.get_param_as_string('avatarStyle'), - ctx.get_file('avatar', default=b'')) - ctx.session.add(user) - ctx.session.commit() - return _serialize(ctx, user, force_show_email=True) - else: - raise errors.ValidationError('User Registration Disabled') + auth.verify_privilege(ctx.user, 'users:create') + name = ctx.get_param_as_string('name') + password = ctx.get_param_as_string('password') + email = ctx.get_param_as_string('email', default='') + user = users.create_user(name, password, email) + if ctx.has_param('rank'): + users.update_user_rank(user, ctx.get_param_as_string('rank'), ctx.user) + if ctx.has_param('avatarStyle'): + users.update_user_avatar( + user, + ctx.get_param_as_string('avatarStyle'), + ctx.get_file('avatar', default=b'')) + ctx.session.add(user) + ctx.session.commit() + return _serialize(ctx, user, force_show_email=True) @rest.routes.get('/user/(?P[^/]+)/?')