From 1380bf705a1a44f9bb0c06f0f36c6dab46ba1e12 Mon Sep 17 00:00:00 2001 From: Shell Turner Date: Fri, 9 Sep 2016 18:21:31 +0100 Subject: [PATCH] Fix CAS support by using a temporary Matrix client Signed-off-by: Shell Turner --- src/Signup.js | 10 ++++++++++ src/components/structures/login/Login.js | 6 +++++- src/components/views/login/CasLogin.js | 13 +++---------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/Signup.js b/src/Signup.js index 1ac92f3218..eaf1906059 100644 --- a/src/Signup.js +++ b/src/Signup.js @@ -6,6 +6,7 @@ var MatrixClientPeg = require("./MatrixClientPeg"); var SignupStages = require("./SignupStages"); var dis = require("./dispatcher"); var q = require("q"); +var url = require("url"); const EMAIL_STAGE_TYPE = "m.login.email.identity"; @@ -413,6 +414,15 @@ class Login extends Signup { throw error; }); } + + redirectToCas() { + var client = this._createTemporaryClient(); + var parsedUrl = url.parse(window.location.href, true); + parsedUrl.query["homeserver"] = client.getHomeserverUrl(); + parsedUrl.query["identityServer"] = client.getIdentityServerUrl(); + var casUrl = client.getCasLoginUrl(url.format(parsedUrl)); + window.location.href = casUrl; + } } module.exports.Register = Register; diff --git a/src/components/structures/login/Login.js b/src/components/structures/login/Login.js index 8025504857..3139d020a6 100644 --- a/src/components/structures/login/Login.js +++ b/src/components/structures/login/Login.js @@ -90,6 +90,10 @@ module.exports = React.createClass({ }).done(); }, + onCasLogin: function() { + this._loginLogic.redirectToCas(); + }, + _onLoginAsGuestClick: function() { var self = this; self.setState({ @@ -225,7 +229,7 @@ module.exports = React.createClass({ ); case 'm.login.cas': return ( - + ); default: if (!step) { diff --git a/src/components/views/login/CasLogin.js b/src/components/views/login/CasLogin.js index 5c89fd3706..c818586d52 100644 --- a/src/components/views/login/CasLogin.js +++ b/src/components/views/login/CasLogin.js @@ -16,26 +16,19 @@ limitations under the License. 'use strict'; -var MatrixClientPeg = require("../../../MatrixClientPeg"); var React = require('react'); -var url = require("url"); module.exports = React.createClass({ displayName: 'CasLogin', - onCasClicked: function(ev) { - var cli = MatrixClientPeg.get(); - var parsedUrl = url.parse(window.location.href, true); - parsedUrl.query["homeserver"] = cli.getHomeserverUrl(); - parsedUrl.query["identityServer"] = cli.getIdentityServerUrl(); - var casUrl = MatrixClientPeg.get().getCasLoginUrl(url.format(parsedUrl)); - window.location.href = casUrl; + propTypes: { + onSubmit: React.PropTypes.func, // fn() }, render: function() { return (
- +
); }