Call through to password login
This commit is contained in:
parent
05eda88ea2
commit
8826eb60cc
|
@ -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);
|
||||
},
|
||||
|
||||
|
|
|
@ -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}/>
|
||||
<div className="mx_Login_error">
|
||||
{ loader }
|
||||
|
|
Loading…
Reference in New Issue