Skip to content

Commit

Permalink
add an api endpoint to retrieve django settings needed to render unau…
Browse files Browse the repository at this point in the history
…thenticated pages
  • Loading branch information
kflemin committed Jan 27, 2025
1 parent e8b9748 commit d028f4f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from config.views import robots_txt
from seed.api.base.urls import urlpatterns as api
from seed.landing.views import CustomLoginView, password_reset_complete, password_reset_confirm, password_reset_done
from seed.views.main import angular_js_tests, health_check, version
from seed.views.main import angular_js_tests, health_check, version, noauth_settings

schema_view = get_schema_view(
openapi.Info(
Expand Down Expand Up @@ -54,6 +54,7 @@ def trigger_error(request):
re_path(r"^robots\.txt", robots_txt, name="robots_txt"),
# API
re_path(r"^api/health_check/$", health_check, name="health_check"),
re_path(r"^api/noauth_settings/$", noauth_settings, name="noauth_settings"),
re_path(r"^api/swagger/$", schema_view.with_ui("swagger", cache_timeout=0), name="schema-swagger-ui"),
re_path(r"^api/token/$", TokenObtainPairView.as_view(), name="token_obtain_pair"),
re_path(r"^api/token/refresh/$", TokenRefreshView.as_view(), name="token_refresh"),
Expand Down
12 changes: 12 additions & 0 deletions seed/views/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,18 @@ def health_check(request):
status=(200 if success else 418),
)

@api_endpoint
@ajax_request
@api_view(["GET"])
def noauth_settings(request):
"""
Returns django settings needed to render no-auth pages
"""
# include sign-up page?
enable_sign_up = settings.INCLUDE_ACCT_REG

return JsonResponse({"include_signup": enable_sign_up})


@api_endpoint
@ajax_request
Expand Down

0 comments on commit d028f4f

Please sign in to comment.