Skip to content

Commit

Permalink
disable in-game registration
Browse files Browse the repository at this point in the history
  • Loading branch information
nekoraw committed Dec 12, 2023
1 parent b2c86fb commit ec89b75
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
22 changes: 16 additions & 6 deletions app/api/domains/osu.py
Original file line number Diff line number Diff line change
Expand Up @@ -1829,6 +1829,13 @@ async def peppyDMHandler():

""" ingame registration """

async def parse_errors(errors: Mapping[str, list[str]]):
errors = {k: ["\n".join(v)] for k, v in errors.items()}
errors_full = {"form_error": {"user": errors}}
return ORJSONResponse(
content=errors_full,
status_code=status.HTTP_400_BAD_REQUEST,
)

@router.post("/users")
async def register_account(
Expand All @@ -1854,6 +1861,14 @@ async def register_account(
# are safe for registration.
errors: Mapping[str, list[str]] = defaultdict(list)

if app.settings.DISABLE_INGAME_REGISTRATION:
error_message = f"O registro está desabilitado. Se registre pelo site em https://{app.settings.DOMAIN}/."
errors = {
"username": [error_message],
"user_email": [error_message],
"password": [error_message]
}
return await parse_errors(errors)
# Usernames must:
# - be within 2-12 characters in length
# - not contain both ' ' and '_', one is fine
Expand Down Expand Up @@ -1935,12 +1950,7 @@ async def register_account(

if errors:
# we have errors to send back, send them back delimited by newlines.
errors = {k: ["\n".join(v)] for k, v in errors.items()}
errors_full = {"form_error": {"user": errors}}
return ORJSONResponse(
content=errors_full,
status_code=status.HTTP_400_BAD_REQUEST,
)
return await parse_errors(errors)

if check == 0:
# the client isn't just checking values,
Expand Down
1 change: 1 addition & 0 deletions app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def read_list(value: str) -> list[str]:

DEBUG = read_bool(os.environ["DEBUG"])
REDIRECT_OSU_URLS = read_bool(os.environ["REDIRECT_OSU_URLS"])
DISABLE_INGAME_REGISTRATION = read_bool(os.environ["DISABLE_INGAME_REGISTRATION"])

PP_CACHED_ACCURACIES = [int(acc) for acc in read_list(os.environ["PP_CACHED_ACCS"])]

Expand Down
1 change: 1 addition & 0 deletions manual.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ DEBUG=False
# redirect beatmaps, beatmapsets, and forum
# pages of maps to the official osu! website
REDIRECT_OSU_URLS=True
DISABLE_INGAME_REGISTRATION=True

PP_CACHED_ACCS=90,95,98,99,100

Expand Down

0 comments on commit ec89b75

Please sign in to comment.