save and restore the URL of the referring page when redirecting to login page
This commit is contained in:
parent
7e6d52d81b
commit
8782890efd
@ -1 +1 @@
|
||||
Subproject commit 985bc77a65e8a404132f33f3bcb45494ecd8d380
|
||||
Subproject commit 285fffd97bf38b0f74fd3e2a5f6e4370856188f9
|
||||
@ -0,0 +1,64 @@
|
||||
// Copyright (C) 2024 Michael Becker <alcexhim@gmail.com>
|
||||
//
|
||||
// This file is part of Mocha.NET.
|
||||
//
|
||||
// Mocha.NET is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Mocha.NET is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Mocha.NET. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
using System.Text.Json.Nodes;
|
||||
using MBS.Web;
|
||||
|
||||
namespace Mocha.Core.UI.Server.Commands;
|
||||
|
||||
public class GlobalsCommand : OmsServerCommand
|
||||
{
|
||||
public override IEnumerable<string> UriPatterns => new string[] { "/globals/{iid}" };
|
||||
|
||||
protected override void ProcessInternal(WebServerProcessRequestEventArgs e, Oms oms, OmsContext ctx, StreamWriter sw)
|
||||
{
|
||||
if (oms.TryParseInstanceRef(Variables["iid"], out InstanceHandle h))
|
||||
{
|
||||
if (e.Context.Request.Method == "POST")
|
||||
{
|
||||
string value = e.Context.Request.Form["value"];
|
||||
ctx.SetGlobal(h, value);
|
||||
|
||||
e.Context.Response.ResponseCode = 200;
|
||||
e.Context.Response.ResponseText = "OK";
|
||||
e.Context.Response.ContentType = "application/json";
|
||||
|
||||
JsonObject json = new JsonObject();
|
||||
json.Add("result", "success");
|
||||
sw.Write(json.ToJsonString());
|
||||
|
||||
Console.Error.WriteLine("uis: globals: setting '{0}' = '{1}'", oms.GetGlobalIdentifier(h), value);
|
||||
}
|
||||
else
|
||||
{
|
||||
string value = ctx.GetGlobal<string>(h);
|
||||
|
||||
e.Context.Response.ResponseCode = 200;
|
||||
e.Context.Response.ResponseText = "OK";
|
||||
e.Context.Response.ContentType = "application/json";
|
||||
|
||||
JsonObject json = new JsonObject();
|
||||
json.Add("result", "success");
|
||||
json.Add("value", value);
|
||||
sw.Write(json.ToJsonString());
|
||||
|
||||
Console.Error.WriteLine("uis: globals: getting '{0}' = '{1}'", oms.GetGlobalIdentifier(h), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -415,6 +415,8 @@ namespace Mocha.Core
|
||||
public static Guid Build_UI_Response_Method__uses__Executable_returning_Element { get; } = new Guid("{6f066ec6-b978-4627-81da-78fee1bed5e5}");
|
||||
public static Guid Executable_returning_Element__used_by__Build_UI_Response_Method { get; } = new Guid("{0e662556-ca79-43fe-9a50-57ad22df65de}");
|
||||
|
||||
public static Guid Build_UI_Response_Method__gets_target_url_from__Executable_returning_Attribute { get; } = new Guid("{6c09db3b-6fc9-4bf6-ab16-a49bc7d4101b}");
|
||||
|
||||
public static Guid Control_Transaction_Method__processes__Element { get; } = new Guid("{24bc1dc0-d6cc-44ff-86ba-1360ebd59f3a}");
|
||||
public static Guid Element__processed_by__Control_Transaction_Method { get; } = new Guid("{0f182291-6784-47b3-a8d3-d2f6ebf3950c}");
|
||||
public static Guid Control_Transaction_Method__uses__Build_Response_Method_Binding { get; } = new Guid("{d8f2f0cc-54a2-4004-a383-8c1321495531}");
|
||||
|
||||
@ -46,7 +46,7 @@ public class EvaluateBooleanExpressionMethodImplementation : MethodImplementatio
|
||||
InstanceHandle source = oms.GetRelatedInstance(method, oms.GetInstance(KnownRelationshipGuids.Evaluate_Boolean_Expression_Method__has_source__Executable_returning_Work_Data));
|
||||
InstanceHandle comparison = oms.GetRelatedInstance(method, oms.GetInstance(KnownRelationshipGuids.Evaluate_Boolean_Expression_Method__uses__Boolean_Operator));
|
||||
|
||||
Console.Error.WriteLine("EBE - source {0}", oms.GetGlobalIdentifier(source));
|
||||
// Console.Error.WriteLine("EBE - source {0}", oms.GetGlobalIdentifier(source));
|
||||
|
||||
InstanceHandle rsource = oms.Execute(context, source);
|
||||
object? rsource_valueraw = context.GetWorkData(rsource);
|
||||
|
||||
@ -1347,7 +1347,7 @@ public abstract class Oms
|
||||
}
|
||||
private string _GetInstanceTextHack(InstanceHandle inst)
|
||||
{
|
||||
Console.Error.WriteLine("!!! HACK !!! GetInstanceTextHack !!! HACK !!!");
|
||||
// Console.Error.WriteLine("!!! HACK !!! GetInstanceTextHack !!! HACK !!!");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (IsInstanceOf(inst, GetInstance(KnownInstanceGuids.Classes.Relationship)))
|
||||
{
|
||||
@ -2042,7 +2042,29 @@ public abstract class Oms
|
||||
Console.Error.WriteLine("----> ok, executing method {0}", executesMethod.GlobalIdentifier);
|
||||
|
||||
// execute BRMB
|
||||
string targetURL = GetAttributeValue<string>(executesMethod, GetInstance(KnownAttributeGuids.Text.TargetURL));
|
||||
string targetURLAttr = GetAttributeValue<string>(executesMethod, GetInstance(KnownAttributeGuids.Text.TargetURL));
|
||||
string targetURL = targetURLAttr;
|
||||
|
||||
InstanceHandle usesTargetURLFromExecutableReturningAttribute = GetRelatedInstance(executesMethod, GetInstance(KnownRelationshipGuids.Build_UI_Response_Method__gets_target_url_from__Executable_returning_Attribute));
|
||||
if (usesTargetURLFromExecutableReturningAttribute != InstanceHandle.Empty)
|
||||
{
|
||||
if (IsInstanceOf(usesTargetURLFromExecutableReturningAttribute, GetInstance(KnownInstanceGuids.Classes.TextAttribute)))
|
||||
{
|
||||
targetURL = ctx.GetGlobal<string>(usesTargetURLFromExecutableReturningAttribute);
|
||||
}
|
||||
else
|
||||
{
|
||||
InstanceHandle h = Execute(ctx, usesTargetURLFromExecutableReturningAttribute);
|
||||
if (h != InstanceHandle.Empty)
|
||||
{
|
||||
targetURL = ctx.GetWorkData<string>(h);
|
||||
if (targetURL == null)
|
||||
{
|
||||
targetURL = targetURLAttr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (targetURL != null)
|
||||
{
|
||||
return new RedirectResponse(targetURL);
|
||||
|
||||
@ -211,6 +211,10 @@ public class OmsContext
|
||||
{
|
||||
return (T)(_GlobalData[parm]);
|
||||
}
|
||||
else if (typeof(T) == typeof(string))
|
||||
{
|
||||
return (T)((object)_GlobalData[parm].ToString());
|
||||
}
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user