pass the access token to the DGT TS

infinitescroll-v2
Thibault Duplessis 2020-09-07 21:00:32 +02:00
parent 3ecfe50de9
commit b2fa70ad4c
3 changed files with 9 additions and 7 deletions

View File

@ -32,9 +32,9 @@ final class DgtCtrl(env: Env) extends LilaController(env) {
def play =
Auth { implicit ctx => me =>
findToken(me) map { t =>
if (t.isEmpty) Redirect(routes.DgtCtrl.config())
else Ok(views.html.dgt.play)
findToken(me) map {
case None => Redirect(routes.DgtCtrl.config())
case Some(t) => Ok(views.html.dgt.play(t))
}
}

View File

@ -6,6 +6,7 @@ import scala.util.chaining._
import lila.api.Context
import lila.app.templating.Environment._
import lila.app.ui.ScalatagsTemplate._
import lila.oauth.AccessToken
object dgt {
@ -44,8 +45,8 @@ object dgt {
)
)
def play(implicit ctx: Context) =
layout("play", embedJsUnsafeLoadThen("lichessDgt.playPage()"))(
def play(token: AccessToken)(implicit ctx: Context) =
layout("play", embedJsUnsafeLoadThen(s"""lichessDgt.playPage("${token.id.value}")"""))(
h1("DGT - play"),
div(id := "dgt-play-zone")("Do the thing here.")
)

View File

@ -1,4 +1,4 @@
export default function() {
export default function(token: string) {
// here's the new setting keys
[
'dgt-livechess-url',
@ -12,7 +12,8 @@ export default function() {
});
// put your UI in there
const root = document.getElementById('dgt-play-zone');
const root = document.getElementById('dgt-play-zone') as HTMLDivElement;
// and your code in here.
root.innerHTML = 'token: ' + token
}