You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-18 05:42:00 +03:00
Update CAS login to return url rather than update location as the JS SDK may not be run within a browser env
This commit is contained in:
@@ -1722,12 +1722,14 @@ MatrixClient.prototype.loginWithSAML2 = function(relayState, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} redirectUrl URL to which to be redirect to after
|
* @param {string} redirectUrl URL to which to be redirected to after
|
||||||
* HS authenticates with CAS and issues login token
|
* HS authenticates with CAS and issues login token
|
||||||
* Will redirect to homeserver to complete CAS login
|
* @return {string} CAS login URL
|
||||||
*/
|
*/
|
||||||
MatrixClient.prototype.loginWithCas = function(redirectUrl) {
|
MatrixClient.prototype.getCasLoginUrl = function(redirectUrl) {
|
||||||
this._http.redirect("/login/cas/redirect", {"redirectUrl": redirectUrl}, httpApi.PREFIX_V1);
|
return this._http.getUrl("/login/cas/redirect", {
|
||||||
|
"redirectUrl": redirectUrl
|
||||||
|
}, httpApi.PREFIX_V1);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -296,13 +296,23 @@ 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) {
|
/**
|
||||||
|
* Form and return a homeserver request URL based on the given path
|
||||||
|
* params and prefix.
|
||||||
|
* @param {string} path The HTTP path <b>after</b> the supplied prefix e.g.
|
||||||
|
* "/createRoom".
|
||||||
|
* @param {Object} queryParams A dict of query params (these will NOT be
|
||||||
|
* urlencoded).
|
||||||
|
* @param {string} prefix The full prefix to use e.g.
|
||||||
|
* "/_matrix/client/v2_alpha".
|
||||||
|
* @return {string} URL
|
||||||
|
*/
|
||||||
|
getUrl: function(path, queryParams, prefix) {
|
||||||
var queryString = "";
|
var queryString = "";
|
||||||
if (queryParams) {
|
if (queryParams) {
|
||||||
queryString = "?" + utils.encodeParams(queryParams);
|
queryString = "?" + utils.encodeParams(queryParams);
|
||||||
}
|
}
|
||||||
var fullUri = this.opts.baseUrl + prefix + path + queryString;
|
return this.opts.baseUrl + prefix + path + queryString;
|
||||||
window.location.href = fullUri;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_request: function(callback, method, uri, queryParams, data) {
|
_request: function(callback, method, uri, queryParams, data) {
|
||||||
|
Reference in New Issue
Block a user