2023-10-06 17:50:05 +02:00
|
|
|
from django.conf import settings
|
2023-10-06 16:13:17 +02:00
|
|
|
from django.http import HttpRequest, HttpResponse
|
|
|
|
from django.shortcuts import render
|
|
|
|
|
|
|
|
|
2024-03-05 15:42:09 +01:00
|
|
|
def config_error(
|
|
|
|
request: HttpRequest,
|
|
|
|
error_name: str,
|
|
|
|
*,
|
2024-07-12 02:30:23 +02:00
|
|
|
go_back_to_url: str | None = None,
|
|
|
|
go_back_to_url_name: str | None = None,
|
2024-03-05 15:42:09 +01:00
|
|
|
) -> HttpResponse:
|
2023-10-06 17:50:05 +02:00
|
|
|
assert "/" not in error_name
|
|
|
|
context = {
|
|
|
|
"error_name": error_name,
|
2024-03-05 15:42:09 +01:00
|
|
|
"go_back_to_url": go_back_to_url or "/login/",
|
|
|
|
"go_back_to_url_name": go_back_to_url_name or "the login page",
|
2023-10-06 16:13:17 +02:00
|
|
|
}
|
2023-10-06 17:50:05 +02:00
|
|
|
if settings.DEVELOPMENT:
|
|
|
|
context["auth_settings_path"] = "zproject/dev-secrets.conf"
|
|
|
|
context["client_id_key_name"] = f"social_auth_{error_name}_key"
|
|
|
|
else:
|
|
|
|
context["auth_settings_path"] = "/etc/zulip/settings.py"
|
|
|
|
context["client_id_key_name"] = f"SOCIAL_AUTH_{error_name.upper()}_KEY"
|
2023-10-06 16:13:17 +02:00
|
|
|
|
2023-10-06 18:16:22 +02:00
|
|
|
return render(request, f"zerver/config_error/{error_name}.html", context=context, status=500)
|