1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-09-03 08:42:03 +03:00

Merge pull request #42 from stevenhammerton/sh-token-login

SH - CAS / Login token login
This commit is contained in:
Kegsay
2015-11-06 14:34:48 +00:00
2 changed files with 30 additions and 13 deletions

View File

@@ -1749,27 +1749,25 @@ MatrixClient.prototype.loginWithSAML2 = function(relayState, callback) {
}; };
/** /**
* @param {module:client.callback} callback Optional. * @param {string} redirectUrl The URL to redirect to after the HS
* @return {module:client.Promise} Resolves: TODO * authenticates with CAS.
* @return {module:http-api.MatrixError} Rejects: with an error response. * @return {string} The HS URL to hit to begin the CAS login process.
*/ */
MatrixClient.prototype.getCasServer = function(callback) { MatrixClient.prototype.getCasLoginUrl = function(redirectUrl) {
return this._http.request( return this._http.getUrl("/login/cas/redirect", {
callback, "GET", "/login/cas", undefined, undefined "redirectUrl": redirectUrl
); }, httpApi.PREFIX_V1);
}; };
/** /**
* @param {string} ticket (Received from CAS) * @param {string} token Login token previously received from homeserver
* @param {string} service Service to which the token was granted
* @param {module:client.callback} callback Optional. * @param {module:client.callback} callback Optional.
* @return {module:client.Promise} Resolves: TODO * @return {module:client.Promise} Resolves: TODO
* @return {module:http-api.MatrixError} Rejects: with an error response. * @return {module:http-api.MatrixError} Rejects: with an error response.
*/ */
MatrixClient.prototype.loginWithCas = function(ticket, service, callback) { MatrixClient.prototype.loginWithToken = function(token, callback) {
return this.login("m.login.cas", { return this.login("m.login.token", {
ticket: ticket, token: token
service: service
}, callback); }, callback);
}; };

View File

@@ -296,6 +296,25 @@ module.exports.MatrixHttpApi.prototype = {
return this._request(callback, method, fullUri, queryParams, data); return this._request(callback, method, fullUri, queryParams, data);
}, },
/**
* 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 = "";
if (queryParams) {
queryString = "?" + utils.encodeParams(queryParams);
}
return this.opts.baseUrl + prefix + path + queryString;
},
_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(