From 9d8d4e4896a79bb919f3b1b7dc859f1a0a0bda7c Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 4 Aug 2015 16:30:41 +0100 Subject: [PATCH] Support email login --- src/controllers/templates/Login.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/controllers/templates/Login.js b/src/controllers/templates/Login.js index 37a95785..6fecee0a 100644 --- a/src/controllers/templates/Login.js +++ b/src/controllers/templates/Login.js @@ -71,10 +71,17 @@ module.exports = { var formVals = this.getFormVals(); - MatrixClientPeg.get().login('m.login.password', { - 'user': formVals.username, - 'password': formVals.password - }).done(function(data) { + var loginParams = { + password: formVals.password + }; + if (formVals.username.indexOf('@') > 0) { + loginParams.medium = 'email'; + loginParams.address = formVals.username; + } else { + loginParams.user = formVals.username; + } + + MatrixClientPeg.get().login('m.login.password', loginParams).done(function(data) { MatrixClientPeg.replaceUsingAccessToken( self.state.hs_url, self.state.is_url, data.user_id, data.access_token