From eefa863855642bc02ed0d56d39a6de63631d0385 Mon Sep 17 00:00:00 2001 From: lone-cloud Date: Fri, 30 Oct 2015 13:38:55 -0700 Subject: [PATCH] better bridge username authentication --- .../components/bridge-finder/component.js | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/app/pods/components/bridge-finder/component.js b/app/pods/components/bridge-finder/component.js index 6a9abe1..cd0310b 100644 --- a/app/pods/components/bridge-finder/component.js +++ b/app/pods/components/bridge-finder/component.js @@ -119,17 +119,10 @@ export default Em.Component.extend({ contentType: 'application/json', type: 'POST' }).done((result, status)=>{ - if (status === 'success') { - if (!result[0].error) { - this.setProperties({ - bridgeUsername: result[0].success.username, - bridgePingIntervalHandle: null - }); - - this.get('storage').set('huegasm.bridgeUsername', result[0].success.username); - clearInterval(this.get('bridgePingIntervalHandle')); - } - this.set('bridgeAuthenticateError', result[0].internalipaddress); + if (status === 'success' && !result[0].error) { + this.clearBridgePingIntervalHandle(); + this.set('bridgeUsername', result[0].success.username); + this.get('storage').set('huegasm.bridgeUsername', result[0].success.username); } this.set('bridgeAuthenticateReachedStatus', status); @@ -137,10 +130,15 @@ export default Em.Component.extend({ this.incrementProperty('bridgeUserNamePingIntervalProgress', this.get('bridgeUsernamePingIntervalTime')/bridgeUsernamePingMaxTime*100); } else { - clearInterval(this.get('bridgePingIntervalHandle')); + this.clearBridgePingIntervalHandle(); } }, + clearBridgePingIntervalHandle(){ + clearInterval(this.get('bridgePingIntervalHandle')); + this.set('bridgePingIntervalHandle', null); + }, + isAuthenticating: function(){ return this.get('bridgePingIntervalHandle') !== null; }.property('bridgePingIntervalHandle')