Skip to content

Commit 5a7dad6

Browse files
authored
Merge pull request #20073 from lichess-org/oauth-modal-fix
fix oauth authorization page for `web:mod` scope
2 parents 3cef9c9 + 02eed14 commit 5a7dad6

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

modules/oauth/src/main/ui/AuthorizeUi.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ final class AuthorizeUi(helpers: Helpers)(lightUserFallback: UserId => LightUser
2828
case None => strong(code(prompt.redirectUri.origin))
2929
),
3030
prompt.redirectUri.insecure.option(flashMessage("warning")("Does not use a secure connection")),
31-
postForm(action := s"${routes.OAuth.authorizeApply}?${ctx.req.rawQueryString}")(
31+
postForm(
32+
id := "oauth-authorize",
33+
action := s"${routes.OAuth.authorizeApply}?${ctx.req.rawQueryString}"
34+
)(
3235
p(
3336
"Grant access to your ",
3437
strong(otherUserRequested.fold(me.username)(_.name)),
@@ -55,7 +58,6 @@ final class AuthorizeUi(helpers: Helpers)(lightUserFallback: UserId => LightUser
5558
cls := s"button${danger.so(" button-red ok-cancel-confirm text")} disabled",
5659
dataIcon := danger.option(Icon.CautionTriangle),
5760
disabled := true,
58-
id := "oauth-authorize",
5961
title := s"The website ${prompt.redirectUri.host | prompt.redirectUri.withoutQuery} will get access to your Lichess account. Continue?"
6062
)("Authorize")
6163
),

ui/bits/src/bits.oauth.inline.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
// ensure maximum browser compatibility here,
22
// as the oauth page can be embedded in very dubious webviews
33

4-
const el: HTMLElement = document.getElementById('oauth-authorize')!;
4+
const form: HTMLElement = document.getElementById('oauth-authorize')!;
5+
const submitBtn: HTMLButtonElement = form.querySelector('button')!;
56

67
setTimeout(
78
function () {
8-
el.removeAttribute('disabled');
9-
el.classList.remove('disabled');
9+
submitBtn.removeAttribute('disabled');
10+
submitBtn.classList.remove('disabled');
1011
},
11-
el.classList.contains('button-red') ? 5000 : 2000,
12+
submitBtn.classList.contains('button-red') ? 5000 : 2000,
1213
);
1314

14-
el.addEventListener('click', function () {
15+
form.addEventListener('submit', function () {
1516
setTimeout(function () {
1617
document.querySelector<HTMLDivElement>('.oauth form')!.remove();
1718
const oauthTop = document.querySelector<HTMLDivElement>('.oauth__top')!;
@@ -20,5 +21,4 @@ el.addEventListener('click', function () {
2021
successDiv.textContent = 'All set! You can now close this page and return to the app.';
2122
oauthTop.insertAdjacentElement('afterend', successDiv);
2223
}, 500);
23-
return true;
2424
});

0 commit comments

Comments
 (0)