From 8826eb60cc0a4401adf59380c58def4c081aca63 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 12 Nov 2015 15:16:29 +0000 Subject: [PATCH] Call through to password login --- .../vector/views/organisms/PasswordLogin.js | 3 +- src/skins/vector/views/pages/LoginPage.js | 29 +++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/skins/vector/views/organisms/PasswordLogin.js b/src/skins/vector/views/organisms/PasswordLogin.js index ff277ceddb..fabd71d67e 100644 --- a/src/skins/vector/views/organisms/PasswordLogin.js +++ b/src/skins/vector/views/organisms/PasswordLogin.js @@ -32,7 +32,8 @@ module.exports = React.createClass({displayName: 'PasswordLogin', }; }, - onSubmitForm: function() { + onSubmitForm: function(ev) { + ev.preventDefault(); this.props.onSubmit(this.state.username, this.state.password); }, diff --git a/src/skins/vector/views/pages/LoginPage.js b/src/skins/vector/views/pages/LoginPage.js index 7b4f636ff3..00f46a37ff 100644 --- a/src/skins/vector/views/pages/LoginPage.js +++ b/src/skins/vector/views/pages/LoginPage.js @@ -54,15 +54,30 @@ module.exports = React.createClass({displayName: 'LoginPage', }, onPasswordLogin: function(username, password) { - // TODO - console.log("onPasswordLogin %s %s", username, password); + var self = this; + self.setState({ + busy: true + }); + + this._loginLogic.loginViaPassword(username, password).then(function(data) { + self.props.onLoggedIn(data); + }, function(error) { + self._setErrorTextFromError(error); + }).finally(function() { + self.setState({ + busy: false + }); + }); }, onHsUrlChanged: function(newHsUrl) { - console.log("onHsUrlChanged %s", newHsUrl); this._initLoginLogic(newHsUrl); }, + onIsUrlChanged: function(newIsUrl) { + this._initLoginLogic(null, newIsUrl); + }, + _initLoginLogic: function(hsUrl, isUrl) { var self = this; hsUrl = hsUrl || this.state.enteredHomeserverUrl; @@ -97,6 +112,13 @@ module.exports = React.createClass({displayName: 'LoginPage', }, _setErrorTextFromError: function(err) { + if (err.friendlyText) { + this.setState({ + errorText: err.friendlyText + }); + return; + } + var errCode = err.errcode; if (!errCode && err.httpStatus) { errCode = "HTTP " + err.httpStatus; @@ -153,6 +175,7 @@ module.exports = React.createClass({displayName: 'LoginPage', defaultHsUrl={this.props.homeserverUrl} defaultIsUrl={this.props.identityServerUrl} onHsUrlChanged={this.onHsUrlChanged} + onIsUrlChanged={this.onIsUrlChanged} delayTimeMs={1000}/>
{ loader }