Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit ce332d0

Browse files
Kerryrichvdh
andauthored
Fix: hide unsupported login elements (#11185)
* hide unsupported login elements * Update src/components/structures/auth/Login.tsx Co-authored-by: Richard van der Hoff <[email protected]> --------- Co-authored-by: Richard van der Hoff <[email protected]>
1 parent 2034cce commit ce332d0

File tree

3 files changed

+42
-12
lines changed

3 files changed

+42
-12
lines changed

src/components/structures/auth/Login.tsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -392,19 +392,17 @@ export default class LoginComponent extends React.PureComponent<IProps, IState>
392392
// look for a flow where we understand all of the steps.
393393
const supportedFlows = flows.filter(this.isSupportedFlow);
394394

395-
if (supportedFlows.length > 0) {
395+
this.setState({
396+
flows: supportedFlows,
397+
});
398+
399+
if (supportedFlows.length === 0) {
396400
this.setState({
397-
flows: supportedFlows,
401+
errorText: _t(
402+
"This homeserver doesn't offer any login flows that are supported by this client.",
403+
),
398404
});
399-
return;
400405
}
401-
402-
// we got to the end of the list without finding a suitable flow.
403-
this.setState({
404-
errorText: _t(
405-
"This homeserver doesn't offer any login flows which are supported by this client.",
406-
),
407-
});
408406
},
409407
(err) => {
410408
this.setState({

src/i18n/strings/en_EN.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3569,7 +3569,7 @@
35693569
"General failure": "General failure",
35703570
"This homeserver does not support login using email address.": "This homeserver does not support login using email address.",
35713571
"Failed to perform homeserver discovery": "Failed to perform homeserver discovery",
3572-
"This homeserver doesn't offer any login flows which are supported by this client.": "This homeserver doesn't offer any login flows which are supported by this client.",
3572+
"This homeserver doesn't offer any login flows that are supported by this client.": "This homeserver doesn't offer any login flows that are supported by this client.",
35733573
"Syncing…": "Syncing…",
35743574
"Signing In…": "Signing In…",
35753575
"If you've joined lots of rooms, this might take a while": "If you've joined lots of rooms, this might take a while",

test/components/structures/auth/Login-test.tsx

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,38 @@ describe("Login", function () {
216216
expect(platform.startSingleSignOn.mock.calls[1][0].baseUrl).toBe("https://server2");
217217
});
218218

219+
it("should handle updating to a server with no supported flows", async () => {
220+
mockClient.loginFlows.mockResolvedValue({
221+
flows: [
222+
{
223+
type: "m.login.sso",
224+
},
225+
],
226+
});
227+
228+
const { container, rerender } = render(getRawComponent());
229+
await waitForElementToBeRemoved(() => screen.queryAllByLabelText("Loading…"));
230+
231+
// update the mock for the new server with no supported flows
232+
mockClient.loginFlows.mockResolvedValue({
233+
flows: [
234+
{
235+
type: "just something weird",
236+
},
237+
],
238+
});
239+
// render with a new server
240+
rerender(getRawComponent("https://server2"));
241+
await waitForElementToBeRemoved(() => screen.queryAllByLabelText("Loading…"));
242+
243+
expect(
244+
screen.getByText("This homeserver doesn't offer any login flows that are supported by this client."),
245+
).toBeInTheDocument();
246+
247+
// no sso button because server2 doesnt support sso
248+
expect(container.querySelector(".mx_SSOButton")).not.toBeInTheDocument();
249+
});
250+
219251
it("should show single Continue button if OIDC MSC3824 compatibility is given by server", async () => {
220252
mockClient.loginFlows.mockResolvedValue({
221253
flows: [
@@ -289,7 +321,7 @@ describe("Login", function () {
289321
await waitForElementToBeRemoved(() => screen.queryAllByLabelText("Loading…"));
290322

291323
expect(
292-
screen.getByText("This homeserver doesn't offer any login flows which are supported by this client."),
324+
screen.getByText("This homeserver doesn't offer any login flows that are supported by this client."),
293325
).toBeInTheDocument();
294326
});
295327

0 commit comments

Comments
 (0)