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';
async function checkCrypto() {
@ -64,9 +65,9 @@ export default async function capabilities() {
const crypto = await checkCrypto();
const nativeStreams = checkStreams();
const polyStreams = nativeStreams ? false : polyfillStreams();
let account = false;
let account = typeof AUTH_CONFIG !== 'undefined';
try {
account = !!localStorage;
account = account && !!localStorage;
} catch (e) {
// nevermind
}

View File

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

View File

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