From 8b7dd918a8929f80088086d714e157197bfc8b45 Mon Sep 17 00:00:00 2001 From: Mo Bitar Date: Thu, 21 Dec 2017 12:49:28 -0600 Subject: [PATCH 1/2] Auth error handling for non-json responses --- .../javascripts/app/services/authManager.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/app/services/authManager.js b/app/assets/javascripts/app/services/authManager.js index 9763e716e..cf78c6000 100644 --- a/app/assets/javascripts/app/services/authManager.js +++ b/app/assets/javascripts/app/services/authManager.js @@ -101,7 +101,10 @@ angular.module('app.frontend') callback(response); }, function(response){ console.error("Error getting auth params", response); - callback(null); + if(typeof response !== 'object') { + response = {error: {message: "A server error occurred while trying to sign in. Please try again."}}; + } + callback(response); }) } @@ -120,6 +123,11 @@ angular.module('app.frontend') this.login = function(url, email, password, ephemeral, callback) { this.getAuthParamsForEmail(url, email, function(authParams){ + if(authParams.error) { + callback(authParams); + return; + } + if(!authParams || !authParams.pw_cost) { callback({error : {message: "Invalid email or password."}}); return; @@ -158,6 +166,9 @@ angular.module('app.frontend') callback(response); }.bind(this), function(response){ console.error("Error logging in", response); + if(typeof response !== 'object') { + response = {error: {message: "A server error occurred while trying to sign in. Please try again."}}; + } callback(response); }) @@ -199,10 +210,12 @@ angular.module('app.frontend') httpManager.postAbsolute(requestUrl, params, function(response){ this.setEphemeral(ephemeral); this.handleAuthResponse(response, email, url, authParams, keys); - callback(response); }.bind(this), function(response){ console.error("Registration error", response); + if(typeof response !== 'object') { + response = {error: {message: "A server error occurred while trying to register. Please try again."}}; + } callback(response); }.bind(this)) }.bind(this)); From fdbd2638a4ba13516a39ea8940e08463acf08f69 Mon Sep 17 00:00:00 2001 From: Mo Bitar Date: Thu, 21 Dec 2017 12:52:37 -0600 Subject: [PATCH 2/2] Remove erroneous css id --- app/assets/templates/frontend/editor.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/templates/frontend/editor.html.haml b/app/assets/templates/frontend/editor.html.haml index a33cb2a5a..e6cb98055 100644 --- a/app/assets/templates/frontend/editor.html.haml +++ b/app/assets/templates/frontend/editor.html.haml @@ -59,4 +59,4 @@ #editor-pane-component-stack .component.component-stack-border{"ng-repeat" => "component in ctrl.componentStack", "ng-if" => "component.active", "ng-show" => "!component.ignoreEvents", "id" => "{{'component-' + component.uuid}}", "ng-mouseover" => "component.showExit = true", "ng-mouseleave" => "component.showExit = false"} .exit-button.body-text-color{"ng-if" => "component.showExit", "ng-click" => "ctrl.disableComponentForCurrentItem(component, true)"} × - %iframe#note-tags-iframe{"ng-src" => "{{component.url | trusted}}", "frameBorder" => "0", "sandbox" => "allow-scripts allow-top-navigation-by-user-activation allow-popups allow-popups-to-escape-sandbox allow-modals", "data-component-id" => "{{component.uuid}}"} + %iframe{"ng-src" => "{{component.url | trusted}}", "frameBorder" => "0", "sandbox" => "allow-scripts allow-top-navigation-by-user-activation allow-popups allow-popups-to-escape-sandbox allow-modals", "data-component-id" => "{{component.uuid}}"}