1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-28 05:03:59 +03:00

Change login with CAS to redirect to HS for CAS login

This commit is contained in:
Steven Hammerton
2015-11-05 15:19:04 +00:00
parent d241f5b3eb
commit c3097979f2
2 changed files with 14 additions and 21 deletions

View File

@@ -1722,28 +1722,12 @@ MatrixClient.prototype.loginWithSAML2 = function(relayState, callback) {
}; };
/** /**
* @param {module:client.callback} callback Optional. * @param {string} redirectUrl URL to which to be redirect to after
* @return {module:client.Promise} Resolves: TODO * HS authenticates with CAS and issues login token
* @return {module:http-api.MatrixError} Rejects: with an error response. * Will redirect to homeserver to complete CAS login
*/ */
MatrixClient.prototype.getCasServer = function(callback) { MatrixClient.prototype.loginWithCas = function(redirectUrl) {
return this._http.request( this._http.redirect("/login/cas/redirect", {"redirectUrl": redirectUrl}, httpApi.PREFIX_V1);
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);
}; };
/** /**

View File

@@ -296,6 +296,15 @@ module.exports.MatrixHttpApi.prototype = {
return this._request(callback, method, fullUri, queryParams, data); 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) { _request: function(callback, method, uri, queryParams, data) {
if (callback !== undefined && !utils.isFunction(callback)) { if (callback !== undefined && !utils.isFunction(callback)) {
throw Error( throw Error(