Skip to content

Commit

Permalink
feat: Feature flag ENABLE_PHONE_LOGIN (#5424)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yserz committed Dec 14, 2018
1 parent 62df1f1 commit d50d37b
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 24 deletions.
1 change: 1 addition & 0 deletions .env
Expand Up @@ -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=""
Expand Down
2 changes: 2 additions & 0 deletions app/script/auth/config.ts
Expand Up @@ -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;
};
Expand All @@ -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,
};
Expand Down
33 changes: 20 additions & 13 deletions app/script/auth/page/Login.tsx
Expand Up @@ -421,14 +421,16 @@ class Login extends React.Component<CombinedProps, State> {
{_(loginStrings.ssoLogin)}
</Link>
</Column>
<Column>
<Link
href={EXTERNAL_ROUTE.PHONE_LOGIN + window.location.search}
data-uie-name="go-sign-in-phone"
>
{_(loginStrings.phoneLogin)}
</Link>
</Column>
{config.FEATURE.ENABLE_PHONE_LOGIN && (
<Column>
<Link
href={URLUtil.pathWithParams(EXTERNAL_ROUTE.PHONE_LOGIN)}
data-uie-name="go-sign-in-phone"
>
{_(loginStrings.phoneLogin)}
</Link>
</Column>
)}
</Columns>
</div>
) : (
Expand All @@ -438,11 +440,16 @@ class Login extends React.Component<CombinedProps, State> {
{_(loginStrings.forgotPassword)}
</Link>
</Column>
<Column>
<Link href={EXTERNAL_ROUTE.PHONE_LOGIN + window.location.search} data-uie-name="go-sign-in-phone">
{_(loginStrings.phoneLogin)}
</Link>
</Column>
{config.FEATURE.ENABLE_PHONE_LOGIN && (
<Column>
<Link
href={URLUtil.pathWithParams(EXTERNAL_ROUTE.PHONE_LOGIN)}
data-uie-name="go-sign-in-phone"
>
{_(loginStrings.phoneLogin)}
</Link>
</Column>
)}
</Columns>
)}
</ContainerXS>
Expand Down
25 changes: 18 additions & 7 deletions app/script/config.js
Expand Up @@ -19,6 +19,8 @@

window.z = window.z || {};

const env = window.wire.env;

window.z.config = {
ACCENT_ID: {
BLUE: 1,
Expand All @@ -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: {
Expand Down Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion app/script/main/app.js
Expand Up @@ -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)} : {};
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/script/user/UserRepository.js
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion app/script/util/util.js
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion app/script/view_model/LoadingViewModel.js
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions server/ServerConfig.ts
Expand Up @@ -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;
};
Expand Down
1 change: 1 addition & 0 deletions server/config.ts
Expand Up @@ -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,
},
Expand Down

0 comments on commit d50d37b

Please sign in to comment.