Fix for crosslang v0.0.10
This commit is contained in:
@@ -11,4 +11,4 @@ ENV TYTDDIR=/data
|
|||||||
|
|
||||||
EXPOSE 3255
|
EXPOSE 3255
|
||||||
|
|
||||||
ENTRYPOINT ["crossvm","/app/tytd2025.crvm","--port=3255"]
|
ENTRYPOINT ["crosslang","vm","/app/tytd2025.crvm","--port=3255"]
|
||||||
|
|||||||
@@ -139,8 +139,8 @@ class TYTDApp {
|
|||||||
{
|
{
|
||||||
var incorrect=false;
|
var incorrect=false;
|
||||||
const redirect = ctx.QueryParams.TryGetFirst("redirect") ?? "/";
|
const redirect = ctx.QueryParams.TryGetFirst("redirect") ?? "/";
|
||||||
const username = ctx.QueryParams.TryGetFirst("username") ?? "";
|
const username = ctx.BodyParams.TryGetFirst("username") ?? "";
|
||||||
const password = ctx.QueryParams.TryGetFirst("password") ?? "";
|
const password = ctx.BodyParams.TryGetFirst("password") ?? "";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -218,16 +218,16 @@ class TYTDApp {
|
|||||||
{
|
{
|
||||||
if(ctx.Method == "POST")
|
if(ctx.Method == "POST")
|
||||||
{
|
{
|
||||||
const from = ctx.QueryParams.TryGetFirstInt("from");
|
const from = ctx.BodyParams.TryGetFirstInt("from");
|
||||||
switch(from)
|
switch(from)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
const enablePlugins = ctx.QueryParams.GetFirstBoolean("enablePlugins");
|
const enablePlugins = ctx.BodyParams.GetFirstBoolean("enablePlugins");
|
||||||
const tag = ctx.QueryParams.TryGetFirst("tag") ?? "UnknownPC";
|
const tag = ctx.BodyParams.TryGetFirst("tag") ?? "UnknownPC";
|
||||||
const pollHours = ctx.QueryParams.TryGetFirstInt("pollHours") ?? 3;
|
const pollHours = ctx.BodyParams.TryGetFirstInt("pollHours") ?? 3;
|
||||||
const pollMinutes = ctx.QueryParams.TryGetFirstInt("pollMinutes") ?? 0;
|
const pollMinutes = ctx.BodyParams.TryGetFirstInt("pollMinutes") ?? 0;
|
||||||
const pollSeconds = ctx.QueryParams.TryGetFirstInt("pollSeconds") ?? 0;
|
const pollSeconds = ctx.BodyParams.TryGetFirstInt("pollSeconds") ?? 0;
|
||||||
|
|
||||||
|
|
||||||
this.OOBE_STATE.tag = tag;
|
this.OOBE_STATE.tag = tag;
|
||||||
@@ -248,7 +248,7 @@ class TYTDApp {
|
|||||||
case 3:
|
case 3:
|
||||||
{
|
{
|
||||||
|
|
||||||
const createUser = (ctx.QueryParams.TryGetFirst("user") ?? "no")=="yes";
|
const createUser = (ctx.BodyParams.TryGetFirst("user") ?? "no")=="yes";
|
||||||
|
|
||||||
var seconds = this.OOBE_STATE.pollSeconds;
|
var seconds = this.OOBE_STATE.pollSeconds;
|
||||||
seconds += this.OOBE_STATE.pollMinutes * 60;
|
seconds += this.OOBE_STATE.pollMinutes * 60;
|
||||||
@@ -386,18 +386,38 @@ class TYTDApp {
|
|||||||
}
|
}
|
||||||
else if(ctx.Path == "/passwd")
|
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")
|
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")
|
else if(ctx.Path == "/newuser")
|
||||||
@@ -405,14 +425,14 @@ class TYTDApp {
|
|||||||
var error = null;
|
var error = null;
|
||||||
if(ctx.Method == "POST")
|
if(ctx.Method == "POST")
|
||||||
{
|
{
|
||||||
const username = ctx.QueryParams.TryGetFirst("username");
|
const username = ctx.BodyParams.TryGetFirst("username");
|
||||||
const password = ctx.QueryParams.TryGetFirst("password");
|
const password = ctx.BodyParams.TryGetFirst("password");
|
||||||
const confirm = ctx.QueryParams.TryGetFirst("confirm");
|
const confirm = ctx.BodyParams.TryGetFirst("confirm");
|
||||||
const isAdmin = ctx.QueryParams.GetFirstBoolean("isAdmin");
|
const isAdmin = ctx.BodyParams.GetFirstBoolean("isAdmin");
|
||||||
const canUsePlugins = ctx.QueryParams.GetFirstBoolean("canUsePlugins");
|
const canUsePlugins = ctx.BodyParams.GetFirstBoolean("canUsePlugins");
|
||||||
const canManagePlugins = ctx.QueryParams.GetFirstBoolean("canManagePlugins");
|
const canManagePlugins = ctx.BodyParams.GetFirstBoolean("canManagePlugins");
|
||||||
const canDownloadDB = ctx.QueryParams.GetFirstBoolean("canDownloadDB");
|
const canDownloadDB = ctx.BodyParams.GetFirstBoolean("canDownloadDB");
|
||||||
const redirect = ctx.QueryParams.TryGetFirst("redirect") ?? "/";
|
|
||||||
var flags = 0;
|
var flags = 0;
|
||||||
if(isAdmin) flags |= UserFlags.AdminFlag;
|
if(isAdmin) flags |= UserFlags.AdminFlag;
|
||||||
if(canUsePlugins) flags |= UserFlags.PluginFlag;
|
if(canUsePlugins) flags |= UserFlags.PluginFlag;
|
||||||
@@ -434,12 +454,6 @@ class TYTDApp {
|
|||||||
else {
|
else {
|
||||||
error = this.TYTD.CreateAccount(ctx, username, password, flags);
|
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));
|
ctx.WithMimeType("text/html").SendText(Pages.NewUser(error));
|
||||||
return true;
|
return true;
|
||||||
@@ -790,7 +804,7 @@ class TYTDApp {
|
|||||||
}
|
}
|
||||||
else if(ctx.Method == "POST")
|
else if(ctx.Method == "POST")
|
||||||
{
|
{
|
||||||
var description =ctx.QueryParams.TryGetFirst("description");
|
var description =ctx.BodyParams.TryGetFirst("description");
|
||||||
this.TYTD.SetPersonalListDescription(name,description);
|
this.TYTD.SetPersonalListDescription(name,description);
|
||||||
ctx.WithMimeType("text/html").SendText(Components.PersonalListDescription(this.TYTD,name,false));
|
ctx.WithMimeType("text/html").SendText(Components.PersonalListDescription(this.TYTD,name,false));
|
||||||
|
|
||||||
@@ -848,10 +862,10 @@ class TYTDApp {
|
|||||||
{
|
{
|
||||||
if(whoami.username != user)
|
if(whoami.username != user)
|
||||||
{
|
{
|
||||||
const isAdmin = ctx.QueryParams.GetFirstBoolean("isAdmin");
|
const isAdmin = ctx.BodyParams.GetFirstBoolean("isAdmin");
|
||||||
const canUsePlugins = ctx.QueryParams.GetFirstBoolean("canUsePlugins");
|
const canUsePlugins = ctx.BodyParams.GetFirstBoolean("canUsePlugins");
|
||||||
const canManagePlugins = ctx.QueryParams.GetFirstBoolean("canManagePlugins");
|
const canManagePlugins = ctx.BodyParams.GetFirstBoolean("canManagePlugins");
|
||||||
const canDownloadDB = ctx.QueryParams.GetFirstBoolean("canDownloadDB");
|
const canDownloadDB = ctx.BodyParams.GetFirstBoolean("canDownloadDB");
|
||||||
var flags = 0;
|
var flags = 0;
|
||||||
if(isAdmin) flags |= UserFlags.AdminFlag;
|
if(isAdmin) flags |= UserFlags.AdminFlag;
|
||||||
if(canUsePlugins) flags |= UserFlags.PluginFlag;
|
if(canUsePlugins) flags |= UserFlags.PluginFlag;
|
||||||
@@ -926,11 +940,11 @@ class TYTDApp {
|
|||||||
tag
|
tag
|
||||||
enablePlugins
|
enablePlugins
|
||||||
*/
|
*/
|
||||||
var enablePlugins = ctx.QueryParams.GetFirstBoolean("enablePlugins");
|
var enablePlugins = ctx.BodyParams.GetFirstBoolean("enablePlugins");
|
||||||
var tag = ctx.QueryParams.TryGetFirst("tag");
|
var tag = ctx.BodyParams.TryGetFirst("tag");
|
||||||
var hours = ctx.QueryParams.TryGetFirstInt("hours");
|
var hours = ctx.BodyParams.TryGetFirstInt("hours");
|
||||||
var minutes = ctx.QueryParams.TryGetFirstInt("minutes");
|
var minutes = ctx.BodyParams.TryGetFirstInt("minutes");
|
||||||
var seconds = ctx.QueryParams.TryGetFirstInt("seconds");
|
var seconds = ctx.BodyParams.TryGetFirstInt("seconds");
|
||||||
|
|
||||||
if(TypeOf(tag) == "String" && TypeOf(hours) == "Long" && TypeOf(minutes) == "Long" && TypeOf(seconds) == "Long")
|
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")
|
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));
|
ctx.WithMimeType("text/html").SendText(Pages.YouTubeAnonyPlaylist(video_ids));
|
||||||
return true;
|
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))
|
if(TypeIsString(name))
|
||||||
{
|
{
|
||||||
const nameParts=video_ids.Split(",");
|
const nameParts=video_ids.Split(",");
|
||||||
Console.WriteLine(nameParts);
|
//Console.WriteLine(nameParts);
|
||||||
each(var item : nameParts)
|
each(var item : nameParts)
|
||||||
{
|
{
|
||||||
|
|
||||||
this.TYTD.AddToPersonalList(name,item);
|
this.TYTD.AddToPersonalList(name,item);
|
||||||
}
|
}
|
||||||
Console.WriteLine(name);
|
//Console.WriteLine(name);
|
||||||
ctx.SendRedirect($"/list?name={Net.Http.UrlEncode(name)}",303);
|
ctx.SendRedirect($"/list?name={Net.Http.UrlEncode(name)}",303);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(ctx.Path == "/playlist")
|
else if(ctx.Path == "/playlist")
|
||||||
{
|
{
|
||||||
@@ -1089,9 +1111,9 @@ class TYTDApp {
|
|||||||
{
|
{
|
||||||
if(!UserFlags.CanManagePlugins(this.TYTD.IsLoggedIn(ctx))) return false;
|
if(!UserFlags.CanManagePlugins(this.TYTD.IsLoggedIn(ctx))) return false;
|
||||||
var data = {
|
var data = {
|
||||||
name = ctx.QueryParams.TryGetFirst("name"),
|
name = ctx.BodyParams.TryGetFirst("name"),
|
||||||
version = ctx.QueryParams.TryGetFirst("version"),
|
version = ctx.BodyParams.TryGetFirst("version"),
|
||||||
action = ctx.QueryParams.TryGetFirst("action")
|
action = ctx.BodyParams.TryGetFirst("action")
|
||||||
};
|
};
|
||||||
|
|
||||||
var mustConfirm = false;
|
var mustConfirm = false;
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
func Pages.ChangePassword(redirect,incorrect)
|
func Pages.ChangePassword(redirect,error)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const html = <null>
|
const html = <null>
|
||||||
<if(incorrect)>
|
<if(TypeIsString(error))>
|
||||||
<true>
|
<true>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<h5>The password could not be changed</h5>
|
<h5>{error}</h5>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
</true>
|
</true>
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ func Pages.OobePage2(tytd,ctx)
|
|||||||
<div class="small-margin">Security</div>
|
<div class="small-margin">Security</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</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">
|
<input type="hidden" name="page" value="2">
|
||||||
<div class="field suffix border round">
|
<div class="field suffix border round">
|
||||||
<select name="server">
|
<select name="server">
|
||||||
|
|||||||
Reference in New Issue
Block a user