login: Make authentication_methods data available to JavaScript.

This is intended to simplify overriding these buttons' controls in the
desktop app to do the authentication in the user's default browser.
This commit is contained in:
Mateusz Mandera
2020-01-31 15:03:55 +01:00
committed by Tim Abbott
parent b685d506ad
commit 6aacc4195e
5 changed files with 50 additions and 4 deletions

View File

@@ -178,6 +178,15 @@ def login_context(request: HttpRequest) -> Dict[str, Any]:
context['external_authentication_methods'] = get_external_method_dicts(realm)
context['no_auth_enabled'] = no_auth_enabled
# Include another copy of external_authentication_methods in page_params for use
# by the desktop client. We expand it with IDs of the <button> elements corresponding
# to the authentication methods.
context['page_params'] = dict(
external_authentication_methods = get_external_method_dicts(realm)
)
for auth_dict in context['page_params']['external_authentication_methods']:
auth_dict['button_id_suffix'] = "auth_button_%s" % (auth_dict['name'],)
return context
def latest_info_context() -> Dict[str, str]: