From 2d902eeadd5a2f005b4d5d3920f9c51ce060d7bc Mon Sep 17 00:00:00 2001 From: Arunmozhi Date: Wed, 14 Aug 2024 07:19:29 +1000 Subject: [PATCH] fix: prevent redirects to /undefined after saml auth When a user authenticates using SAML, but their accounts aren't linked, they land on the login page with the message to link their accounts. If the `OC_REDIRECT_ON_TPA_UNLINKED_ACCOUNT` value is not set, they are redirected to `/undefined`. This commit checks that the `redirectURL` is a valid non-empty string before performing the redirect. The bug was introduced in 91f8d36, so this can be safely dropped once that temporary commit is removed from our branches. For Redwood, the relevant commit hash is 64f5deab99. Internal-ref: https://tasks.opencraft.com/browse/BB-9010 (cherry picked from commit 9ade4eac447f5b90d271b26cfee1c852c2e3c559) --- lms/static/js/student_account/views/LoginView.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lms/static/js/student_account/views/LoginView.js b/lms/static/js/student_account/views/LoginView.js index 9b7ce2e19908..0bf8fa854903 100644 --- a/lms/static/js/student_account/views/LoginView.js +++ b/lms/static/js/student_account/views/LoginView.js @@ -268,7 +268,9 @@ this.clearFormErrors(); this.renderThirdPartyAuthWarning(); } - window.location.href = redirectURL; + if (typeof redirectURL === "string" && redirectURL.length) { + window.location.href = redirectURL; + } } else { this.renderErrors(this.defaultFormErrorsTitle, this.errors); }