Просмотр исходного кода

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
Jessica Lawshe 7 лет назад
Родитель
Сommit
7c533fa5fb

+ 7 - 0
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 },

+ 11 - 0
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.<br/><a href="/institutional-login">institutional login</a>'
+    }
+  }
+}
+
 class SAMLUserNotFoundError extends BackwardCompatibleError {
   constructor(arg) {
     super(arg)
@@ -119,6 +129,7 @@ module.exports = {
   InvalidError,
   NotInV2Error,
   SAMLIdentityExistsError,
+  SAMLSessionDataMissing,
   SAMLUserNotFoundError,
   SLInV2Error,
   ThirdPartyIdentityExistsError,

+ 7 - 1
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.',