Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions modules/oauth/src/main/ui/AuthorizeUi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ final class AuthorizeUi(helpers: Helpers)(lightUserFallback: UserId => LightUser
case None => strong(code(prompt.redirectUri.origin))
),
prompt.redirectUri.insecure.option(flashMessage("warning")("Does not use a secure connection")),
postForm(action := s"${routes.OAuth.authorizeApply}?${ctx.req.rawQueryString}")(
postForm(
id := "oauth-authorize",
action := s"${routes.OAuth.authorizeApply}?${ctx.req.rawQueryString}"
)(
p(
"Grant access to your ",
strong(otherUserRequested.fold(me.username)(_.name)),
Expand All @@ -55,7 +58,6 @@ final class AuthorizeUi(helpers: Helpers)(lightUserFallback: UserId => LightUser
cls := s"button${danger.so(" button-red ok-cancel-confirm text")} disabled",
dataIcon := danger.option(Icon.CautionTriangle),
disabled := true,
id := "oauth-authorize",
title := s"The website ${prompt.redirectUri.host | prompt.redirectUri.withoutQuery} will get access to your Lichess account. Continue?"
)("Authorize")
),
Expand Down
12 changes: 6 additions & 6 deletions ui/bits/src/bits.oauth.inline.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
// ensure maximum browser compatibility here,
// as the oauth page can be embedded in very dubious webviews

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

setTimeout(
function () {
el.removeAttribute('disabled');
el.classList.remove('disabled');
submitBtn.removeAttribute('disabled');
submitBtn.classList.remove('disabled');
},
el.classList.contains('button-red') ? 5000 : 2000,
submitBtn.classList.contains('button-red') ? 5000 : 2000,
);

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