From 027f601887c58f5986f1b1dc07d421ddaf565dd8 Mon Sep 17 00:00:00 2001 From: Mike Nolan Date: Wed, 2 Sep 2026 12:31:31 -0500 Subject: [PATCH] Fix for crosslang v0.0.10 --- Dockerfile | 2 +- .../src/main.tcross | 120 +++++++++++------- .../src/pages/changepassword.tcross | 6 +- .../src/pages/oobe/page2.tcross | 2 +- 4 files changed, 76 insertions(+), 54 deletions(-) diff --git a/Dockerfile b/Dockerfile index d5ab210..e21c64b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,4 +11,4 @@ ENV TYTDDIR=/data EXPOSE 3255 -ENTRYPOINT ["crossvm","/app/tytd2025.crvm","--port=3255"] \ No newline at end of file +ENTRYPOINT ["crosslang","vm","/app/tytd2025.crvm","--port=3255"] diff --git a/Tesses.YouTubeDownloader.Server/src/main.tcross b/Tesses.YouTubeDownloader.Server/src/main.tcross index caff570..04c0730 100644 --- a/Tesses.YouTubeDownloader.Server/src/main.tcross +++ b/Tesses.YouTubeDownloader.Server/src/main.tcross @@ -139,8 +139,8 @@ class TYTDApp { { var incorrect=false; const redirect = ctx.QueryParams.TryGetFirst("redirect") ?? "/"; - const username = ctx.QueryParams.TryGetFirst("username") ?? ""; - const password = ctx.QueryParams.TryGetFirst("password") ?? ""; + const username = ctx.BodyParams.TryGetFirst("username") ?? ""; + const password = ctx.BodyParams.TryGetFirst("password") ?? ""; @@ -218,16 +218,16 @@ class TYTDApp { { if(ctx.Method == "POST") { - const from = ctx.QueryParams.TryGetFirstInt("from"); + const from = ctx.BodyParams.TryGetFirstInt("from"); switch(from) { case 1: { - const enablePlugins = ctx.QueryParams.GetFirstBoolean("enablePlugins"); - const tag = ctx.QueryParams.TryGetFirst("tag") ?? "UnknownPC"; - const pollHours = ctx.QueryParams.TryGetFirstInt("pollHours") ?? 3; - const pollMinutes = ctx.QueryParams.TryGetFirstInt("pollMinutes") ?? 0; - const pollSeconds = ctx.QueryParams.TryGetFirstInt("pollSeconds") ?? 0; + const enablePlugins = ctx.BodyParams.GetFirstBoolean("enablePlugins"); + const tag = ctx.BodyParams.TryGetFirst("tag") ?? "UnknownPC"; + const pollHours = ctx.BodyParams.TryGetFirstInt("pollHours") ?? 3; + const pollMinutes = ctx.BodyParams.TryGetFirstInt("pollMinutes") ?? 0; + const pollSeconds = ctx.BodyParams.TryGetFirstInt("pollSeconds") ?? 0; this.OOBE_STATE.tag = tag; @@ -248,7 +248,7 @@ class TYTDApp { case 3: { - const createUser = (ctx.QueryParams.TryGetFirst("user") ?? "no")=="yes"; + const createUser = (ctx.BodyParams.TryGetFirst("user") ?? "no")=="yes"; var seconds = this.OOBE_STATE.pollSeconds; seconds += this.OOBE_STATE.pollMinutes * 60; @@ -386,18 +386,38 @@ class TYTDApp { } else if(ctx.Path == "/passwd") { - var incorrect=false; + var result = {success=true}; - const password = ctx.QueryParams.TryGetFirst("password") ?? ""; - const newpassword = ctx.QueryParams.TryGetFirst("newpassword") ?? ""; - const confirm = ctx.QueryParams.TryGetFirst("newpassword") ?? ""; + const redirect = ctx.BodyParams.TryGetFirst("redirect") ?? "/login"; + const password = ctx.BodyParams.TryGetFirst("password") ?? ""; + const newpassword = ctx.BodyParams.TryGetFirst("newpassword") ?? ""; + + const confirm = ctx.BodyParams.TryGetFirst("confirm") ?? ""; + const logout = ctx.BodyParams.GetFirstBoolean("logout"); if(ctx.Method == "POST") { - this.TYTD.Passwd(); + //public Passwd(ctx, oldPassword, newPassword, logout) + if(password != newpassword) + { + result = {success = false, reason = "Passwords do not match"}; + } + else + result = this.TYTD.Passwd(ctx, password, newpassword, logout); + + if(result.success) + { + ctx.StatusCode = 307; + ctx.SendRedirect(redirect); + + return true; + } + } - ctx.WithMimeType("text/html").SendText(Pages.ChangePassword(redirect, incorrect)); + + ctx.WithMimeType("text/html").SendText(Pages.ChangePassword(redirect, result.success ? null : result.reason)); + return true; } else if(ctx.Path == "/newuser") @@ -405,14 +425,14 @@ class TYTDApp { var error = null; if(ctx.Method == "POST") { - const username = ctx.QueryParams.TryGetFirst("username"); - const password = ctx.QueryParams.TryGetFirst("password"); - const confirm = ctx.QueryParams.TryGetFirst("confirm"); - const isAdmin = ctx.QueryParams.GetFirstBoolean("isAdmin"); - const canUsePlugins = ctx.QueryParams.GetFirstBoolean("canUsePlugins"); - const canManagePlugins = ctx.QueryParams.GetFirstBoolean("canManagePlugins"); - const canDownloadDB = ctx.QueryParams.GetFirstBoolean("canDownloadDB"); - const redirect = ctx.QueryParams.TryGetFirst("redirect") ?? "/"; + const username = ctx.BodyParams.TryGetFirst("username"); + const password = ctx.BodyParams.TryGetFirst("password"); + const confirm = ctx.BodyParams.TryGetFirst("confirm"); + const isAdmin = ctx.BodyParams.GetFirstBoolean("isAdmin"); + const canUsePlugins = ctx.BodyParams.GetFirstBoolean("canUsePlugins"); + const canManagePlugins = ctx.BodyParams.GetFirstBoolean("canManagePlugins"); + const canDownloadDB = ctx.BodyParams.GetFirstBoolean("canDownloadDB"); + var flags = 0; if(isAdmin) flags |= UserFlags.AdminFlag; if(canUsePlugins) flags |= UserFlags.PluginFlag; @@ -434,12 +454,6 @@ class TYTDApp { else { error = this.TYTD.CreateAccount(ctx, username, password, flags); } - - if(!TypeIsString(error)) - { - ctx.StatusCode=303; - ctx.SendRedirect(redirect); - } } ctx.WithMimeType("text/html").SendText(Pages.NewUser(error)); return true; @@ -790,7 +804,7 @@ class TYTDApp { } else if(ctx.Method == "POST") { - var description =ctx.QueryParams.TryGetFirst("description"); + var description =ctx.BodyParams.TryGetFirst("description"); this.TYTD.SetPersonalListDescription(name,description); ctx.WithMimeType("text/html").SendText(Components.PersonalListDescription(this.TYTD,name,false)); @@ -848,10 +862,10 @@ class TYTDApp { { if(whoami.username != user) { - const isAdmin = ctx.QueryParams.GetFirstBoolean("isAdmin"); - const canUsePlugins = ctx.QueryParams.GetFirstBoolean("canUsePlugins"); - const canManagePlugins = ctx.QueryParams.GetFirstBoolean("canManagePlugins"); - const canDownloadDB = ctx.QueryParams.GetFirstBoolean("canDownloadDB"); + const isAdmin = ctx.BodyParams.GetFirstBoolean("isAdmin"); + const canUsePlugins = ctx.BodyParams.GetFirstBoolean("canUsePlugins"); + const canManagePlugins = ctx.BodyParams.GetFirstBoolean("canManagePlugins"); + const canDownloadDB = ctx.BodyParams.GetFirstBoolean("canDownloadDB"); var flags = 0; if(isAdmin) flags |= UserFlags.AdminFlag; if(canUsePlugins) flags |= UserFlags.PluginFlag; @@ -926,11 +940,11 @@ class TYTDApp { tag enablePlugins */ - var enablePlugins = ctx.QueryParams.GetFirstBoolean("enablePlugins"); - var tag = ctx.QueryParams.TryGetFirst("tag"); - var hours = ctx.QueryParams.TryGetFirstInt("hours"); - var minutes = ctx.QueryParams.TryGetFirstInt("minutes"); - var seconds = ctx.QueryParams.TryGetFirstInt("seconds"); + var enablePlugins = ctx.BodyParams.GetFirstBoolean("enablePlugins"); + var tag = ctx.BodyParams.TryGetFirst("tag"); + var hours = ctx.BodyParams.TryGetFirstInt("hours"); + var minutes = ctx.BodyParams.TryGetFirstInt("minutes"); + var seconds = ctx.BodyParams.TryGetFirstInt("seconds"); if(TypeOf(tag) == "String" && TypeOf(hours) == "Long" && TypeOf(minutes) == "Long" && TypeOf(seconds) == "Long") { @@ -953,32 +967,40 @@ class TYTDApp { else if(ctx.Path == "/watch_videos") { - const video_ids = ctx.QueryParams.TryGetFirst("video_ids"); - if(TypeIsString(video_ids)) + + if(ctx.Method=="GET") { - if(ctx.Method=="GET") + const video_ids = ctx.QueryParams.TryGetFirst("video_ids"); + + if(TypeIsString(video_ids)) { ctx.WithMimeType("text/html").SendText(Pages.YouTubeAnonyPlaylist(video_ids)); return true; } - if(ctx.Method=="POST") + } + if(ctx.Method=="POST") + { + const video_ids = ctx.BodyParams.TryGetFirst("video_ids"); + + if(TypeIsString(video_ids)) { - const name = ctx.QueryParams.TryGetFirst("name"); + const name = ctx.BodyParams.TryGetFirst("name"); if(TypeIsString(name)) { const nameParts=video_ids.Split(","); - Console.WriteLine(nameParts); + //Console.WriteLine(nameParts); each(var item : nameParts) { this.TYTD.AddToPersonalList(name,item); } - Console.WriteLine(name); + //Console.WriteLine(name); ctx.SendRedirect($"/list?name={Net.Http.UrlEncode(name)}",303); return true; } } } + } else if(ctx.Path == "/playlist") { @@ -1089,9 +1111,9 @@ class TYTDApp { { if(!UserFlags.CanManagePlugins(this.TYTD.IsLoggedIn(ctx))) return false; var data = { - name = ctx.QueryParams.TryGetFirst("name"), - version = ctx.QueryParams.TryGetFirst("version"), - action = ctx.QueryParams.TryGetFirst("action") + name = ctx.BodyParams.TryGetFirst("name"), + version = ctx.BodyParams.TryGetFirst("version"), + action = ctx.BodyParams.TryGetFirst("action") }; var mustConfirm = false; diff --git a/Tesses.YouTubeDownloader.Server/src/pages/changepassword.tcross b/Tesses.YouTubeDownloader.Server/src/pages/changepassword.tcross index bb95c0e..98eb16b 100644 --- a/Tesses.YouTubeDownloader.Server/src/pages/changepassword.tcross +++ b/Tesses.YouTubeDownloader.Server/src/pages/changepassword.tcross @@ -1,14 +1,14 @@ -func Pages.ChangePassword(redirect,incorrect) +func Pages.ChangePassword(redirect,error) { const html = - +
-
The password could not be changed
+
{error}
diff --git a/Tesses.YouTubeDownloader.Server/src/pages/oobe/page2.tcross b/Tesses.YouTubeDownloader.Server/src/pages/oobe/page2.tcross index 7d18c19..3ca5d6b 100644 --- a/Tesses.YouTubeDownloader.Server/src/pages/oobe/page2.tcross +++ b/Tesses.YouTubeDownloader.Server/src/pages/oobe/page2.tcross @@ -51,7 +51,7 @@ func Pages.OobePage2(tytd,ctx)
Security
-
+