From 7e5161bf759096ce679b8ff84229403d536a7f5e Mon Sep 17 00:00:00 2001 From: Cynthia Wang Date: Wed, 18 Oct 2023 16:21:48 -0400 Subject: [PATCH] fix: add appcheck for vanilla js --- vanilla-js/index.html | 3 ++- vanilla-js/scripts/FriendlyEats.View.js | 6 ++++++ vanilla-js/scripts/FriendlyEats.js | 17 +++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/vanilla-js/index.html b/vanilla-js/index.html index c715e9161..ce7920c2b 100644 --- a/vanilla-js/index.html +++ b/vanilla-js/index.html @@ -352,7 +352,8 @@

- + + diff --git a/vanilla-js/scripts/FriendlyEats.View.js b/vanilla-js/scripts/FriendlyEats.View.js index 0e66f6a13..cc5b2e764 100644 --- a/vanilla-js/scripts/FriendlyEats.View.js +++ b/vanilla-js/scripts/FriendlyEats.View.js @@ -517,3 +517,9 @@ FriendlyEats.prototype.replaceElement = function(parent, content) { FriendlyEats.prototype.rerender = function() { this.router.navigate(document.location.pathname + '?' + new Date().getTime()); }; + +FriendlyEats.prototype.initAppCheck = function() { + /* + TODO: Initialize and activate App Check + */ +}; diff --git a/vanilla-js/scripts/FriendlyEats.js b/vanilla-js/scripts/FriendlyEats.js index 7220c0f29..e5e8ac77e 100644 --- a/vanilla-js/scripts/FriendlyEats.js +++ b/vanilla-js/scripts/FriendlyEats.js @@ -19,6 +19,21 @@ * Initializes the FriendlyEats app. */ function FriendlyEats() { + const isLocalhost = Boolean( + window.location.hostname === 'localhost' || + // [::1] is the IPv6 localhost address. + window.location.hostname === '[::1]' || + // 127.0.0.1/8 is considered localhost for IPv4. + window.location.hostname.match( + /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ + ) +); + if(isLocalhost) { + /* + TODO: Set up local debug token + */ + } + this.filters = { city: '', price: '', @@ -29,6 +44,8 @@ function FriendlyEats() { this.dialogs = {}; var that = this; + that.initAppCheck(); + firebase.auth().signInAnonymously().then(function() { that.initTemplates(); that.initRouter();