fix: simplify login options

This commit is contained in:
Nya Candy 2021-10-14 20:15:06 +08:00
parent 3243382cbb
commit e8536bd951
No known key found for this signature in database
GPG Key ID: 8B1BE5E86F2E66AE

View File

@ -7,30 +7,27 @@ const authProvider = {
base_url = process.env.REACT_APP_SERVER || base_url; base_url = process.env.REACT_APP_SERVER || base_url;
console.log("login "); console.log("login ");
let options; const options = {
if (username && password) { method: "POST",
options = { body: JSON.stringify(
method: "POST", Object.assign(
body: JSON.stringify({ {
type: "m.login.password", device_id: localStorage.getItem("device_id"),
user: username, initial_device_display_name: "Synapse Admin",
password: password, },
initial_device_display_name: "Synapse Admin", loginToken
}), ? {
}; type: "m.login.token",
} else if (loginToken) { token: loginToken,
options = { }
method: "POST", : {
body: JSON.stringify({ type: "m.login.password",
type: "m.login.token", user: username,
token: loginToken, password: password,
initial_device_display_name: "Synapse Admin", }
}), )
}; ),
} else { };
// Invalid request
return Promise.reject();
}
// use the base_url from login instead of the well_known entry from the // use the base_url from login instead of the well_known entry from the
// server, since the admin might want to access the admin API via some // server, since the admin might want to access the admin API via some