From d50d37b64cabb68af1b1ba5061e8d0542387105b Mon Sep 17 00:00:00 2001 From: Michael Koppen Date: Fri, 14 Dec 2018 14:50:20 +0100 Subject: [PATCH] feat: Feature flag ENABLE_PHONE_LOGIN (#5424) --- .env | 1 + app/script/auth/config.ts | 2 ++ app/script/auth/page/Login.tsx | 33 ++++++++++++++--------- app/script/config.js | 25 ++++++++++++----- app/script/main/app.js | 2 +- app/script/user/UserRepository.js | 2 +- app/script/util/util.js | 2 +- app/script/view_model/LoadingViewModel.js | 2 +- server/ServerConfig.ts | 1 + server/config.ts | 1 + 10 files changed, 47 insertions(+), 24 deletions(-) diff --git a/.env b/.env index 680ca3e59dd..4aba26d93e9 100644 --- a/.env +++ b/.env @@ -15,6 +15,7 @@ ENFORCE_HTTPS="false" FEATURE_CHECK_CONSENT="true" FEATURE_ENABLE_ACCOUNT_REGISTRATION="true" FEATURE_ENABLE_DEBUG="true" +FEATURE_ENABLE_PHONE_LOGIN="true" FEATURE_ENABLE_SSO="true" FEATURE_SHOW_LOADING_INFORMATION="true" GOOGLE_WEBMASTER_ID="" diff --git a/app/script/auth/config.ts b/app/script/auth/config.ts index 9276d45a583..6f93f954853 100644 --- a/app/script/auth/config.ts +++ b/app/script/auth/config.ts @@ -39,6 +39,7 @@ declare global { CHECK_CONSENT: boolean; ENABLE_ACCOUNT_REGISTRATION: boolean; ENABLE_DEBUG: boolean; + ENABLE_PHONE_LOGIN: boolean; ENABLE_SSO: boolean; SHOW_LOADING_INFORMATION: boolean; }; @@ -63,6 +64,7 @@ export const FEATURE = window.wire.env.FEATURE || { CHECK_CONSENT: true, ENABLE_ACCOUNT_REGISTRATION: true, ENABLE_DEBUG: false, + ENABLE_PHONE_LOGIN: true, ENABLE_SSO: false, SHOW_LOADING_INFORMATION: false, }; diff --git a/app/script/auth/page/Login.tsx b/app/script/auth/page/Login.tsx index 5806b2313bb..1420da9dd36 100644 --- a/app/script/auth/page/Login.tsx +++ b/app/script/auth/page/Login.tsx @@ -421,14 +421,16 @@ class Login extends React.Component { {_(loginStrings.ssoLogin)} - - - {_(loginStrings.phoneLogin)} - - + {config.FEATURE.ENABLE_PHONE_LOGIN && ( + + + {_(loginStrings.phoneLogin)} + + + )} ) : ( @@ -438,11 +440,16 @@ class Login extends React.Component { {_(loginStrings.forgotPassword)} - - - {_(loginStrings.phoneLogin)} - - + {config.FEATURE.ENABLE_PHONE_LOGIN && ( + + + {_(loginStrings.phoneLogin)} + + + )} )} diff --git a/app/script/config.js b/app/script/config.js index 9ed490ad016..a1fc7143136 100644 --- a/app/script/config.js +++ b/app/script/config.js @@ -19,6 +19,8 @@ window.z = window.z || {}; +const env = window.wire.env; + window.z.config = { ACCENT_ID: { BLUE: 1, @@ -30,6 +32,15 @@ window.z.config = { YELLOW: 3, }, + FEATURE: { + CHECK_CONSENT: env.FEATURE && env.FEATURE.CHECK_CONSENT, + ENABLE_ACCOUNT_REGISTRATION: env.FEATURE && env.FEATURE.ENABLE_ACCOUNT_REGISTRATION, + ENABLE_DEBUG: env.FEATURE && env.FEATURE.ENABLE_DEBUG, + ENABLE_PHONE_LOGIN: env.FEATURE && env.FEATURE.ENABLE_PHONE_LOGIN, + ENABLE_SSO: env.FEATURE && env.FEATURE.ENABLE_SSO, + SHOW_LOADING_INFORMATION: env.FEATURE && env.FEATURE.SHOW_LOADING_INFORMATION, + }, + LOGGER: { OPTIONS: { domains: { @@ -93,23 +104,23 @@ window.z.config = { URL: { ACCOUNT: { - PRODUCTION: (window.wire.env.URL && window.wire.env.URL.ACCOUNT_BASE) || 'https://account.wire.com', + PRODUCTION: (env.URL && env.URL.ACCOUNT_BASE) || 'https://account.wire.com', STAGING: 'https://wire-account-staging.zinfra.io', }, - PRIVACY_POLICY: window.wire.env.URL && window.wire.env.URL.PRIVACY_POLICY, + PRIVACY_POLICY: env.URL && env.URL.PRIVACY_POLICY, SUPPORT: 'https://support.wire.com', TEAM_SETTINGS: { - PRODUCTION: (window.wire.env.URL && window.wire.env.URL.TEAMS_BASE) || 'https://teams.wire.com', + PRODUCTION: (env.URL && env.URL.TEAMS_BASE) || 'https://teams.wire.com', STAGING: 'https://wire-teams-staging.zinfra.io', }, - TERMS_OF_USE_PERSONAL: window.wire.env.URL && window.wire.env.URL.TERMS_OF_USE_PERSONAL, - TERMS_OF_USE_TEAMS: window.wire.env.URL && window.wire.env.URL.TERMS_OF_USE_TEAMS, + TERMS_OF_USE_PERSONAL: env.URL && env.URL.TERMS_OF_USE_PERSONAL, + TERMS_OF_USE_TEAMS: env.URL && env.URL.TERMS_OF_USE_TEAMS, WEBAPP: { INTERNAL: 'https://wire-webapp-staging.wire.com', - PRODUCTION: window.wire.env.APP_BASE || 'https://app.wire.com', + PRODUCTION: env.APP_BASE || 'https://app.wire.com', STAGING: 'https://wire-webapp-staging.zinfra.io', }, - WEBSITE: window.wire.env.URL && window.wire.env.URL.WEBSITE_BASE, + WEBSITE: env.URL && env.URL.WEBSITE_BASE, }, URL_PATH: { diff --git a/app/script/main/app.js b/app/script/main/app.js index 099bea819f9..214863c0394 100644 --- a/app/script/main/app.js +++ b/app/script/main/app.js @@ -249,7 +249,7 @@ class App { * @returns {Object} All utils */ _setup_utils() { - return window.wire.env.FEATURE.ENABLE_DEBUG ? {debug: new DebugUtil(this.repository)} : {}; + return z.config.FEATURE.ENABLE_DEBUG ? {debug: new DebugUtil(this.repository)} : {}; } /** diff --git a/app/script/user/UserRepository.js b/app/script/user/UserRepository.js index bd8569505db..47b809d9ff8 100644 --- a/app/script/user/UserRepository.js +++ b/app/script/user/UserRepository.js @@ -797,7 +797,7 @@ z.user.UserRepository = class UserRepository { } getMarketingConsent() { - if (!window.wire.env.FEATURE.CHECK_CONSENT) { + if (!z.config.FEATURE.CHECK_CONSENT) { this.logger.warn(`Consent check feature is disabled. Defaulting to '${this.marketingConsent()}'`); return Promise.resolve(); } diff --git a/app/script/util/util.js b/app/script/util/util.js index 261c489a3c1..fa624f03c02 100644 --- a/app/script/util/util.js +++ b/app/script/util/util.js @@ -457,7 +457,7 @@ z.util.isValidEmail = email => { * @returns {boolean} True, if the input a phone number */ z.util.isValidPhoneNumber = phoneNumber => { - const allowDebugPhoneNumbers = window.wire.env.FEATURE.ENABLE_DEBUG; + const allowDebugPhoneNumbers = z.config.FEATURE.ENABLE_DEBUG; const regularExpression = allowDebugPhoneNumbers ? /^\+[0-9]\d{1,14}$/ : /^\+[1-9]\d{1,14}$/; return regularExpression.test(phoneNumber); diff --git a/app/script/view_model/LoadingViewModel.js b/app/script/view_model/LoadingViewModel.js index 26c51595d69..32039ed78d4 100644 --- a/app/script/view_model/LoadingViewModel.js +++ b/app/script/view_model/LoadingViewModel.js @@ -52,7 +52,7 @@ z.viewModel.LoadingViewModel = class LoadingViewModel { case z.string.initDecryption: case z.string.initEvents: { - if (!window.wire.env.FEATURE.SHOW_LOADING_INFORMATION) { + if (!z.config.FEATURE.SHOW_LOADING_INFORMATION) { updatedLoadingMessage = z.l10n.text(messageLocator); break; } diff --git a/server/ServerConfig.ts b/server/ServerConfig.ts index 40feb5fb8d2..186131c28be 100644 --- a/server/ServerConfig.ts +++ b/server/ServerConfig.ts @@ -21,6 +21,7 @@ export interface ServerConfig { CHECK_CONSENT: boolean; ENABLE_ACCOUNT_REGISTRATION: boolean; ENABLE_DEBUG: boolean; + ENABLE_PHONE_LOGIN: boolean; ENABLE_SSO: boolean; SHOW_LOADING_INFORMATION: boolean; }; diff --git a/server/config.ts b/server/config.ts index 28a4da36fee..c130dbd849f 100644 --- a/server/config.ts +++ b/server/config.ts @@ -131,6 +131,7 @@ const config: ServerConfig = { CHECK_CONSENT: process.env.FEATURE_CHECK_CONSENT == 'false' ? false : true, ENABLE_ACCOUNT_REGISTRATION: process.env.FEATURE_ENABLE_ACCOUNT_REGISTRATION == 'false' ? false : true, ENABLE_DEBUG: process.env.FEATURE_ENABLE_DEBUG == 'true' ? true : false, + ENABLE_PHONE_LOGIN: process.env.FEATURE_ENABLE_PHONE_LOGIN == 'false' ? false : true, ENABLE_SSO: process.env.FEATURE_ENABLE_SSO == 'true' ? true : false, SHOW_LOADING_INFORMATION: process.env.FEATURE_SHOW_LOADING_INFORMATION == 'true' ? true : false, },