mirror of https://github.com/vector-im/riot-web
Fix CAS support by using a temporary Matrix client
Signed-off-by: Shell Turner <cam.turn@gmail.com>pull/21833/head
parent
14227b5718
commit
1380bf705a
|
@ -6,6 +6,7 @@ var MatrixClientPeg = require("./MatrixClientPeg");
|
||||||
var SignupStages = require("./SignupStages");
|
var SignupStages = require("./SignupStages");
|
||||||
var dis = require("./dispatcher");
|
var dis = require("./dispatcher");
|
||||||
var q = require("q");
|
var q = require("q");
|
||||||
|
var url = require("url");
|
||||||
|
|
||||||
const EMAIL_STAGE_TYPE = "m.login.email.identity";
|
const EMAIL_STAGE_TYPE = "m.login.email.identity";
|
||||||
|
|
||||||
|
@ -413,6 +414,15 @@ class Login extends Signup {
|
||||||
throw error;
|
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;
|
module.exports.Register = Register;
|
||||||
|
|
|
@ -90,6 +90,10 @@ module.exports = React.createClass({
|
||||||
}).done();
|
}).done();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onCasLogin: function() {
|
||||||
|
this._loginLogic.redirectToCas();
|
||||||
|
},
|
||||||
|
|
||||||
_onLoginAsGuestClick: function() {
|
_onLoginAsGuestClick: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
self.setState({
|
self.setState({
|
||||||
|
@ -225,7 +229,7 @@ module.exports = React.createClass({
|
||||||
);
|
);
|
||||||
case 'm.login.cas':
|
case 'm.login.cas':
|
||||||
return (
|
return (
|
||||||
<CasLogin />
|
<CasLogin onSubmit={this.onCasLogin} />
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
if (!step) {
|
if (!step) {
|
||||||
|
|
|
@ -16,26 +16,19 @@ limitations under the License.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var MatrixClientPeg = require("../../../MatrixClientPeg");
|
|
||||||
var React = require('react');
|
var React = require('react');
|
||||||
var url = require("url");
|
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
displayName: 'CasLogin',
|
displayName: 'CasLogin',
|
||||||
|
|
||||||
onCasClicked: function(ev) {
|
propTypes: {
|
||||||
var cli = MatrixClientPeg.get();
|
onSubmit: React.PropTypes.func, // fn()
|
||||||
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;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<button onClick={this.onCasClicked}>Sign in with CAS</button>
|
<button onClick={this.props.onSubmit}>Sign in with CAS</button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue