Skip to content

Commit 1342f1a

Browse files
wolfogreGiteaBot
authored andcommitted
Show the mismatched ROOT_URL warning on the sign-in page if OAuth2 is enabled (go-gitea#25947)
Since OAuth2 will callback the root URL, if the user starts signing in from a wrong host, Gitea will return 500 because it cannot find the session. <details> <summary>How to reproduce</summary> <img width="901" alt="image" src="https://github.com/go-gitea/gitea/assets/9418365/2c2e255c-e13e-4a11-9be7-b226bee54920"> <img width="1014" alt="image" src="https://github.com/go-gitea/gitea/assets/9418365/b31cfcf6-a320-483d-9ce5-ba8562f065e1"> </details> So show the mismatched ROOT_URL warning on the sign-in page if OAuth2 is enabled. <img width="1015" alt="image" src="https://github.com/go-gitea/gitea/assets/9418365/99e80b17-c790-49a3-bbf2-2bd9396a7daa">
1 parent 5c3662b commit 1342f1a

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

web_src/js/features/admin/common.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export function initAdminCommon() {
1010
}
1111

1212
// check whether appUrl(ROOT_URL) is correct, if not, show an error message
13-
// only admin pages need this check because most templates are using relative URLs now
1413
checkAppUrl();
1514

1615
// New user

web_src/js/features/common-global.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,5 +373,5 @@ export function checkAppUrl() {
373373
return;
374374
}
375375
showGlobalErrorMessage(`Your ROOT_URL in app.ini is "${appUrl}", it's unlikely matching the site you are visiting.
376-
Mismatched ROOT_URL config causes wrong URL links for web UI/mail content/webhook notification.`);
376+
Mismatched ROOT_URL config causes wrong URL links for web UI/mail content/webhook notification/OAuth2 sign-in.`);
377377
}

web_src/js/features/user-auth.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import $ from 'jquery';
2+
import {checkAppUrl} from './common-global.js';
23

34
export function initUserAuthOauth2() {
45
const outer = document.getElementById('oauth2-login-navigator');
56
if (!outer) return;
67
const inner = document.getElementById('oauth2-login-navigator-inner');
78

9+
checkAppUrl();
10+
811
for (const link of outer.querySelectorAll('.oauth-login-link')) {
912
link.addEventListener('click', () => {
1013
inner.classList.add('gt-invisible');

0 commit comments

Comments
 (0)