diff --git a/lib/client.js b/lib/client.js index 5d11df353..685e3d8ca 100644 --- a/lib/client.js +++ b/lib/client.js @@ -1722,28 +1722,12 @@ MatrixClient.prototype.loginWithSAML2 = function(relayState, callback) { }; /** - * @param {module:client.callback} callback Optional. - * @return {module:client.Promise} Resolves: TODO - * @return {module:http-api.MatrixError} Rejects: with an error response. + * @param {string} redirectUrl URL to which to be redirect to after + * HS authenticates with CAS and issues login token + * Will redirect to homeserver to complete CAS login */ -MatrixClient.prototype.getCasServer = function(callback) { - return this._http.request( - callback, "GET", "/login/cas", undefined, undefined - ); -}; - -/** - * @param {string} ticket (Received from CAS) - * @param {string} service Service to which the token was granted - * @param {module:client.callback} callback Optional. - * @return {module:client.Promise} Resolves: TODO - * @return {module:http-api.MatrixError} Rejects: with an error response. - */ -MatrixClient.prototype.loginWithCas = function(ticket, service, callback) { - return this.login("m.login.cas", { - ticket: ticket, - service: service - }, callback); +MatrixClient.prototype.loginWithCas = function(redirectUrl) { + this._http.redirect("/login/cas/redirect", {"redirectUrl": redirectUrl}, httpApi.PREFIX_V1); }; /** diff --git a/lib/http-api.js b/lib/http-api.js index 09b3d4d38..03c498691 100644 --- a/lib/http-api.js +++ b/lib/http-api.js @@ -296,6 +296,15 @@ module.exports.MatrixHttpApi.prototype = { return this._request(callback, method, fullUri, queryParams, data); }, + redirect: function(path, queryParams, prefix) { + var queryString = ""; + if (queryParams) { + queryString = "?" + utils.encodeParams(queryParams); + } + var fullUri = this.opts.baseUrl + prefix + path + queryString; + window.location.href = fullUri; + }, + _request: function(callback, method, uri, queryParams, data) { if (callback !== undefined && !utils.isFunction(callback)) { throw Error(