From 9e169980e3710eaba6dfdfed54d0649d90d81408 Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Thu, 22 Feb 2018 16:18:14 +0200 Subject: [PATCH] Don't query completed steps if not logged in --- monkey_island/cc/ui/src/components/Main.js | 30 ++++++++++++---------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/monkey_island/cc/ui/src/components/Main.js b/monkey_island/cc/ui/src/components/Main.js index d80d70c24..e518c8416 100644 --- a/monkey_island/cc/ui/src/components/Main.js +++ b/monkey_island/cc/ui/src/components/Main.js @@ -26,21 +26,23 @@ let guardicoreLogoImage = require('../images/guardicore-logo.png'); class AppComponent extends AuthComponent { updateStatus = () => { - this.authFetch('/api') - .then(res => res.json()) - .then(res => { - // This check is used to prevent unnecessary re-rendering - let isChanged = false; - for (let step in this.state.completedSteps) { - if (this.state.completedSteps[step] !== res['completed_steps'][step]) { - isChanged = true; - break; + if (this.auth.loggedIn()){ + this.authFetch('/api') + .then(res => res.json()) + .then(res => { + // This check is used to prevent unnecessary re-rendering + let isChanged = false; + for (let step in this.state.completedSteps) { + if (this.state.completedSteps[step] !== res['completed_steps'][step]) { + isChanged = true; + break; + } } - } - if (isChanged) { - this.setState({completedSteps: res['completed_steps']}); - } - }); + if (isChanged) { + this.setState({completedSteps: res['completed_steps']}); + } + }); + } }; renderRoute = (route_path, page_component, is_exact_path = false) => {