Send legacy parameters on login call

To support login on old HSes
pull/21833/head
David Baker 2017-03-14 14:37:18 +00:00
parent 878413f6a4
commit 2c1ac29d30
1 changed files with 10 additions and 0 deletions

View File

@ -111,23 +111,32 @@ export default class Login {
const isEmail = username.indexOf("@") > 0; const isEmail = username.indexOf("@") > 0;
let identifier; let identifier;
let legacyParams; // parameters added to support old HSes
if (phoneCountry && phoneNumber) { if (phoneCountry && phoneNumber) {
identifier = { identifier = {
type: 'm.id.phone', type: 'm.id.phone',
country: phoneCountry, country: phoneCountry,
number: phoneNumber, number: phoneNumber,
}; };
// No legacy support for phone number login
} else if (isEmail) { } else if (isEmail) {
identifier = { identifier = {
type: 'm.id.thirdparty', type: 'm.id.thirdparty',
medium: 'email', medium: 'email',
address: username, address: username,
}; };
legacyParams = {
medium: 'email',
address: username,
};
} else { } else {
identifier = { identifier = {
type: 'm.id.user', type: 'm.id.user',
user: username, user: username,
}; };
legacyParams = {
user: username,
};
} }
const loginParams = { const loginParams = {
@ -135,6 +144,7 @@ export default class Login {
identifier: identifier, identifier: identifier,
initial_device_display_name: this._defaultDeviceDisplayName, initial_device_display_name: this._defaultDeviceDisplayName,
}; };
Object.assign(loginParams, legacyParams);
const client = this._createTemporaryClient(); const client = this._createTemporaryClient();
return client.login('m.login.password', loginParams).then(function(data) { return client.login('m.login.password', loginParams).then(function(data) {