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

Commit 8d4cbde

Browse files
committed
Revert "Improve the UX of the login fallback when using SSO (#7152)"
This was incorrectly merged to `master` instead of develop. This reverts commit 9024634.
1 parent 84a901c commit 8d4cbde

3 files changed

Lines changed: 22 additions & 32 deletions

File tree

changelog.d/7152.feature

Lines changed: 0 additions & 1 deletion
This file was deleted.

synapse/static/client/login/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<body onload="matrixLogin.onLoad()">
1010
<center>
1111
<br/>
12-
<h1 id="title"></h1>
12+
<h1>Log in with one of the following methods</h1>
1313

1414
<span id="feedback" style="color: #f00"></span>
1515

synapse/static/client/login/js/login.js

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,37 @@
11
window.matrixLogin = {
22
endpoint: location.origin + "/_matrix/client/r0/login",
33
serverAcceptsPassword: false,
4+
serverAcceptsCas: false,
45
serverAcceptsSso: false,
56
};
67

7-
var title_pre_auth = "Log in with one of the following methods";
8-
var title_post_auth = "Logging in...";
9-
108
var submitPassword = function(user, pwd) {
119
console.log("Logging in with password...");
12-
set_title(title_post_auth);
1310
var data = {
1411
type: "m.login.password",
1512
user: user,
1613
password: pwd,
1714
};
1815
$.post(matrixLogin.endpoint, JSON.stringify(data), function(response) {
16+
show_login();
1917
matrixLogin.onLogin(response);
2018
}).error(errorFunc);
2119
};
2220

2321
var submitToken = function(loginToken) {
2422
console.log("Logging in with login token...");
25-
set_title(title_post_auth);
2623
var data = {
2724
type: "m.login.token",
2825
token: loginToken
2926
};
3027
$.post(matrixLogin.endpoint, JSON.stringify(data), function(response) {
28+
show_login();
3129
matrixLogin.onLogin(response);
3230
}).error(errorFunc);
3331
};
3432

3533
var errorFunc = function(err) {
36-
// We want to show the error to the user rather than redirecting immediately to the
37-
// SSO portal (if SSO is the only login option), so we inhibit the redirect.
38-
show_login(true);
34+
show_login();
3935

4036
if (err.responseJSON && err.responseJSON.error) {
4137
setFeedbackString(err.responseJSON.error + " (" + err.responseJSON.errcode + ")");
@@ -49,33 +45,26 @@ var setFeedbackString = function(text) {
4945
$("#feedback").text(text);
5046
};
5147

52-
var show_login = function(inhibit_redirect) {
48+
var show_login = function() {
49+
$("#loading").hide();
50+
5351
var this_page = window.location.origin + window.location.pathname;
5452
$("#sso_redirect_url").val(this_page);
5553

56-
// If inhibit_redirect is false, and SSO is the only supported login method, we can
57-
// redirect straight to the SSO page
58-
if (matrixLogin.serverAcceptsSso) {
59-
if (!inhibit_redirect && !matrixLogin.serverAcceptsPassword) {
60-
$("#sso_form").submit();
61-
return;
62-
}
63-
64-
// Otherwise, show the SSO form
65-
$("#sso_form").show();
66-
}
67-
6854
if (matrixLogin.serverAcceptsPassword) {
6955
$("#password_flow").show();
7056
}
7157

72-
if (!matrixLogin.serverAcceptsPassword && !matrixLogin.serverAcceptsSso) {
73-
$("#no_login_types").show();
58+
if (matrixLogin.serverAcceptsSso) {
59+
$("#sso_flow").show();
60+
} else if (matrixLogin.serverAcceptsCas) {
61+
$("#sso_form").attr("action", "/_matrix/client/r0/login/cas/redirect");
62+
$("#sso_flow").show();
7463
}
7564

76-
set_title(title_pre_auth);
77-
78-
$("#loading").hide();
65+
if (!matrixLogin.serverAcceptsPassword && !matrixLogin.serverAcceptsCas && !matrixLogin.serverAcceptsSso) {
66+
$("#no_login_types").show();
67+
}
7968
};
8069

8170
var show_spinner = function() {
@@ -85,15 +74,17 @@ var show_spinner = function() {
8574
$("#loading").show();
8675
};
8776

88-
var set_title = function(title) {
89-
$("#title").text(title);
90-
};
9177

9278
var fetch_info = function(cb) {
9379
$.get(matrixLogin.endpoint, function(response) {
9480
var serverAcceptsPassword = false;
81+
var serverAcceptsCas = false;
9582
for (var i=0; i<response.flows.length; i++) {
9683
var flow = response.flows[i];
84+
if ("m.login.cas" === flow.type) {
85+
matrixLogin.serverAcceptsCas = true;
86+
console.log("Server accepts CAS");
87+
}
9788
if ("m.login.sso" === flow.type) {
9889
matrixLogin.serverAcceptsSso = true;
9990
console.log("Server accepts SSO");
@@ -111,7 +102,7 @@ var fetch_info = function(cb) {
111102
matrixLogin.onLoad = function() {
112103
fetch_info(function() {
113104
if (!try_token()) {
114-
show_login(false);
105+
show_login();
115106
}
116107
});
117108
};

0 commit comments

Comments
 (0)