mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 20:44:04 +00:00
Depending on the kind of config error being shown, different "go back" links may be more appropriate. We probably hard-coded /login/ for it, because these config errors are most commonly used for authentication backend config error, where it makes sense to have /login/ as "go back", because the user most likely indeed got there from the login page. However, for remote_billing_bouncer_not_configured, it doesn't make sense, because the user almost surely is already logged in and got there by clicking "Plan management" inside the gear menu in the logged in app.
29 lines
969 B
Python
29 lines
969 B
Python
from typing import Optional
|
|
|
|
from django.conf import settings
|
|
from django.http import HttpRequest, HttpResponse
|
|
from django.shortcuts import render
|
|
|
|
|
|
def config_error(
|
|
request: HttpRequest,
|
|
error_name: str,
|
|
*,
|
|
go_back_to_url: Optional[str] = None,
|
|
go_back_to_url_name: Optional[str] = None,
|
|
) -> HttpResponse:
|
|
assert "/" not in error_name
|
|
context = {
|
|
"error_name": error_name,
|
|
"go_back_to_url": go_back_to_url or "/login/",
|
|
"go_back_to_url_name": go_back_to_url_name or "the login page",
|
|
}
|
|
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"
|
|
|
|
return render(request, f"zerver/config_error/{error_name}.html", context=context, status=500)
|