From 7c533fa5fbbd15a110566a851bea4f05d8f5de78 Mon Sep 17 00:00:00 2001 From: Jessica Lawshe Date: Thu, 12 Sep 2019 14:59:51 -0500 Subject: [PATCH] Error handling when missing SAML data When logging in and linking, if session data is missing show a more specific error message. GitOrigin-RevId: 32d733f7478180bcce18e1f466ae10255c763997 --- .../web/app/src/Features/Errors/ErrorController.js | 7 +++++++ services/web/app/src/Features/Errors/Errors.js | 11 +++++++++++ services/web/public/src/directives/asyncForm.js | 8 +++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/services/web/app/src/Features/Errors/ErrorController.js b/services/web/app/src/Features/Errors/ErrorController.js index c2ca8e40bf..f481bd17b4 100644 --- a/services/web/app/src/Features/Errors/ErrorController.js +++ b/services/web/app/src/Features/Errors/ErrorController.js @@ -44,6 +44,13 @@ module.exports = ErrorController = { logger.warn({ err: error, url: req.url }, 'invalid name error') res.status(400) res.send(error.message) + } else if (error instanceof Errors.SAMLSessionDataMissing) { + logger.warn( + { err: error, url: req.url }, + 'missing SAML session data error' + ) + res.status(400) + res.send({ accountLinkingError: error.message }) } else { logger.error( { err: error, url: req.url, method: req.method, user }, diff --git a/services/web/app/src/Features/Errors/Errors.js b/services/web/app/src/Features/Errors/Errors.js index c958432b83..a380cfe12f 100644 --- a/services/web/app/src/Features/Errors/Errors.js +++ b/services/web/app/src/Features/Errors/Errors.js @@ -64,6 +64,16 @@ class SAMLIdentityExistsError extends BackwardCompatibleError { } } +class SAMLSessionDataMissing extends BackwardCompatibleError { + constructor(arg) { + super(arg) + if (!this.message) { + this.message = + 'Please resubmit your institutional email.
institutional login' + } + } +} + class SAMLUserNotFoundError extends BackwardCompatibleError { constructor(arg) { super(arg) @@ -119,6 +129,7 @@ module.exports = { InvalidError, NotInV2Error, SAMLIdentityExistsError, + SAMLSessionDataMissing, SAMLUserNotFoundError, SLInV2Error, ThirdPartyIdentityExistsError, diff --git a/services/web/public/src/directives/asyncForm.js b/services/web/public/src/directives/asyncForm.js index 4fcabca628..3f0e1ac41d 100644 --- a/services/web/public/src/directives/asyncForm.js +++ b/services/web/public/src/directives/asyncForm.js @@ -108,7 +108,13 @@ define(['base', 'libs/passfield'], function(App) { return } - if (status === 400) { + if (status === 400 && data.accountLinkingError) { + // Bad Request for account linking + response.message = { + text: data.accountLinkingError, + type: 'error' + } + } else if (status === 400) { // Bad Request response.message = { text: 'Invalid Request. Please correct the data and try again.',