mirror of
https://github.com/go-gitea/gitea.git
synced 2026-04-02 00:59:56 +09:00
Fixes: #36846 1. When there is only on OAuth2 login method, automatically direct to it 2. Fix legacy problems in code, including: * Rename template filename and fix TODO comments * Fix legacy variable names * Add missing SSPI variable for template * Fix unnecessary layout, remove garbage styles * Only do AppUrl(ROOT_URL) check when it is needed (avoid unnecessary warnings to end users) --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
import {checkAppUrl, checkAppUrlScheme} from './common-page.ts';
|
|
|
|
export function initUserCheckAppUrl() {
|
|
if (!document.querySelector('.page-content.user.signin, .page-content.user.signup, .page-content.user.link-account')) return;
|
|
checkAppUrlScheme();
|
|
}
|
|
|
|
export function initUserExternalLogins() {
|
|
const container = document.querySelector('#external-login-navigator');
|
|
if (!container) return;
|
|
|
|
// whether the auth method requires app url check (need consistent ROOT_URL with visited URL)
|
|
let needCheckAppUrl = false;
|
|
for (const link of container.querySelectorAll('.external-login-link')) {
|
|
needCheckAppUrl = needCheckAppUrl || link.getAttribute('data-require-appurl-check') === 'true';
|
|
link.addEventListener('click', () => {
|
|
container.classList.add('is-loading');
|
|
setTimeout(() => {
|
|
// recover previous content to let user try again, usually redirection will be performed before this action
|
|
container.classList.remove('is-loading');
|
|
}, 5000);
|
|
});
|
|
}
|
|
if (needCheckAppUrl) {
|
|
checkAppUrl();
|
|
}
|
|
}
|