Skip to content

Commit 9b6060a

Browse files
committed
Decouple login view & controller
1 parent 64042c9 commit 9b6060a

2 files changed

Lines changed: 27 additions & 6 deletions

File tree

‎skins/base/views/templates/Login.js‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,24 @@ module.exports = React.createClass({
3131
displayName: 'Login',
3232
mixins: [LoginController],
3333

34+
getHsUrl: function() {
35+
return this.refs.serverConfig.getHsUrl();
36+
},
37+
38+
getIsUrl: function() {
39+
return this.refs.serverConfig.getIsUrl();
40+
},
41+
42+
/**
43+
* Gets the form field values for the current login stage
44+
*/
45+
getFormVals: function() {
46+
return {
47+
'username': this.refs.user.getDOMNode().value,
48+
'password': this.refs.pass.getDOMNode().value
49+
};
50+
},
51+
3452
componentForStep: function(step) {
3553
switch (step) {
3654
case 'choose_hs':

‎src/controllers/templates/Login.js‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ module.exports = {
4141
onHSChosen: function(ev) {
4242
ev.preventDefault();
4343
MatrixClientPeg.replaceUsingUrls(
44-
this.refs.serverConfig.getHsUrl(),
45-
this.refs.serverConfig.getIsUrl()
44+
this.getHsUrl(),
45+
this.getIsUrl()
4646
);
4747
this.setState({
48-
hs_url: this.refs.serverConfig.getHsUrl(),
49-
is_url: this.refs.serverConfig.getIsUrl()
48+
hs_url: this.getHsUrl(),
49+
is_url: this.getIsUrl()
5050
});
5151
this.setStep("fetch_stages");
5252
var cli = MatrixClientPeg.get();
@@ -69,9 +69,12 @@ module.exports = {
6969
ev.preventDefault();
7070
this.setState({busy: true});
7171
var that = this;
72+
73+
var formVals = this.getFormVals();
74+
7275
MatrixClientPeg.get().login('m.login.password', {
73-
'user': that.refs.user.getDOMNode().value,
74-
'password': that.refs.pass.getDOMNode().value
76+
'user': formVals.username,
77+
'password': formVals.password
7578
}).then(function(data) {
7679
// XXX: we assume this means we're logged in, but there could be a next stage
7780
MatrixClientPeg.replace(Matrix.createClient({

0 commit comments

Comments
 (0)