24
1
Fork 0

disable capabilities.account when no FXA_CLIENT_ID is set

This commit is contained in:
Danny Coates 2018-09-19 12:53:23 -07:00
parent e3087f008c
commit 93e82cf953
No known key found for this signature in database
GPG Key ID: 4C442633C62E00CB
3 changed files with 11 additions and 6 deletions

View File

@ -1,3 +1,4 @@
/* global AUTH_CONFIG */
import { browserName } from './utils'; import { browserName } from './utils';
async function checkCrypto() { async function checkCrypto() {
@ -64,9 +65,9 @@ export default async function capabilities() {
const crypto = await checkCrypto(); const crypto = await checkCrypto();
const nativeStreams = checkStreams(); const nativeStreams = checkStreams();
const polyStreams = nativeStreams ? false : polyfillStreams(); const polyStreams = nativeStreams ? false : polyfillStreams();
let account = false; let account = typeof AUTH_CONFIG !== 'undefined';
try { try {
account = !!localStorage; account = account && !!localStorage;
} catch (e) { } catch (e) {
// nevermind // nevermind
} }

View File

@ -132,7 +132,7 @@ const conf = convict({
}, },
fxa_client_id: { fxa_client_id: {
format: String, format: String,
default: 'b50ec33d3c9beb6d', // localhost default: '', // disabled
env: 'FXA_CLIENT_ID' env: 'FXA_CLIENT_ID'
} }
}); });

View File

@ -29,8 +29,12 @@ if (config.analytics_id) {
} }
module.exports = async function(req, res) { module.exports = async function(req, res) {
const fxaConfig = await getFxaConfig(); let authConfig = '';
fxaConfig.client_id = config.fxa_client_id; if (config.fxa_client_id) {
const fxaConfig = await getFxaConfig();
fxaConfig.client_id = config.fxa_client_id;
authConfig = `var AUTH_CONFIG = ${JSON.stringify(fxaConfig)};`;
}
/* eslint-disable no-useless-escape */ /* eslint-disable no-useless-escape */
const jsconfig = ` const jsconfig = `
var isIE = /trident\\\/7\.|msie/i.test(navigator.userAgent); var isIE = /trident\\\/7\.|msie/i.test(navigator.userAgent);
@ -53,7 +57,7 @@ module.exports = async function(req, res) {
var DEFAULTS = { var DEFAULTS = {
EXPIRE_SECONDS: ${config.default_expire_seconds} EXPIRE_SECONDS: ${config.default_expire_seconds}
}; };
var AUTH_CONFIG = ${JSON.stringify(fxaConfig)}; ${authConfig};
${ga} ${ga}
${sentry} ${sentry}
`; `;