Fix for crosslang v0.0.10

This commit is contained in:
2026-09-02 12:31:31 -05:00
parent d2f855881c
commit 027f601887
4 changed files with 76 additions and 54 deletions

View File

@@ -11,4 +11,4 @@ ENV TYTDDIR=/data
EXPOSE 3255
ENTRYPOINT ["crossvm","/app/tytd2025.crvm","--port=3255"]
ENTRYPOINT ["crosslang","vm","/app/tytd2025.crvm","--port=3255"]

View File

@@ -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")
{
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")
{
const name = ctx.QueryParams.TryGetFirst("name");
const video_ids = ctx.BodyParams.TryGetFirst("video_ids");
if(TypeIsString(video_ids))
{
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;

View File

@@ -1,14 +1,14 @@
func Pages.ChangePassword(redirect,incorrect)
func Pages.ChangePassword(redirect,error)
{
const html = <null>
<if(incorrect)>
<if(TypeIsString(error))>
<true>
<blockquote>
<h5>The password could not be changed</h5>
<h5>{error}</h5>
</blockquote>
</true>
</if>

View File

@@ -51,7 +51,7 @@ func Pages.OobePage2(tytd,ctx)
<div class="small-margin">Security</div>
</div>
</nav>
<form hx-get="./oobe" hx-target="body" hx-push-url="true">
<form hx-post="./oobe" hx-target="body" hx-push-url="true">
<input type="hidden" name="page" value="2">
<div class="field suffix border round">
<select name="server">