From 578cb4e268f7881cb101df51462d132d0f931212 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Thu, 15 Nov 2018 19:00:37 +0000 Subject: [PATCH] Add 'getSsoLoginUrl' function --- src/base-apis.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/base-apis.js b/src/base-apis.js index 1515ca735..f05c06d7c 100644 --- a/src/base-apis.js +++ b/src/base-apis.js @@ -310,9 +310,23 @@ MatrixBaseApis.prototype.loginWithSAML2 = function(relayState, callback) { * @return {string} The HS URL to hit to begin the CAS login process. */ MatrixBaseApis.prototype.getCasLoginUrl = function(redirectUrl) { - return this._http.getUrl("/login/cas/redirect", { + return this.getSsoLoginUrl(redirectUrl, "cas"); +}; + +/** + * @param {string} redirectUrl The URL to redirect to after the HS + * authenticates with the SSO. + * @param {string} loginType The type of SSO login we are doing (sso or cas). + * Defaults to 'sso'. + * @return {string} The HS URL to hit to begin the SSO login process. + */ +MatrixBaseApis.prototype.getSsoLoginUrl = function(redirectUrl, loginType) { + if (loginType === undefined) { + loginType = "cas"; + } + return this._http.getUrl("/login/"+loginType+"/redirect", { "redirectUrl": redirectUrl, - }, httpApi.PREFIX_UNSTABLE); + }, httpApi.PREFIX_R0); }; /**