From b929c362223f1c72efda035b0e2173baf66968e6 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 16 Oct 2018 09:19:36 -0600 Subject: [PATCH] Documentation++ --- .../login/InteractiveAuthEntryComponents.js | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/components/views/login/InteractiveAuthEntryComponents.js b/src/components/views/login/InteractiveAuthEntryComponents.js index d4c2f58aa9..6e0e5d538a 100644 --- a/src/components/views/login/InteractiveAuthEntryComponents.js +++ b/src/components/views/login/InteractiveAuthEntryComponents.js @@ -225,6 +225,25 @@ export const TermsAuthEntry = React.createClass({ }, componentWillMount: function() { + // example stageParams: + // + // { + // "policies": { + // "privacy_policy": { + // "version": "1.0", + // "en": { + // "name": "Privacy Policy", + // "url": "https://example.org/privacy-1.0-en.html", + // }, + // "fr": { + // "name": "Politique de confidentialité", + // "url": "https://example.org/privacy-1.0-fr.html", + // }, + // }, + // "other_policy": { ... }, + // } + // } + const allPolicies = this.props.stageParams.policies || {}; const prefLang = SettingsStore.getValue("language"); const initToggles = {}; @@ -235,10 +254,13 @@ export const TermsAuthEntry = React.createClass({ // Pick a language based on the user's language, falling back to english, // and finally to the first language available. If there's still no policy // available then the homeserver isn't respecting the spec. - const availableLangs = Object.keys(policy).filter(e => e !== "version"); let langPolicy = policy[prefLang]; - if (!langPolicy) langPolicy = "en"; - if (!langPolicy) langPolicy = policy[availableLangs[0]]; // last resort + if (!langPolicy) langPolicy = policy["en"]; + if (!langPolicy) { + // last resort + const firstLang = Object.keys(policy).find(e => e !== "version"); + langPolicy = policy[firstLang]; + } if (!langPolicy) throw new Error("Failed to find a policy to show the user"); initToggles[policyId] = false;