figuring out how to use cookies to store session state
This commit is contained in:
parent
8a2c7e420f
commit
f4f4f5b270
@ -110,13 +110,15 @@ font-weight: lighter;
|
||||
{
|
||||
base.OnInit(e);
|
||||
|
||||
if (e.Request.Form.ContainsKey("username") && e.Request.Form.ContainsKey("password"))
|
||||
string tenantName = e.Context.Request.GetExtraData<string>("TenantName");
|
||||
if (e.Context.Request.Form.ContainsKey("username") && e.Context.Request.Form.ContainsKey("password"))
|
||||
{
|
||||
if (e.Request.Form["username"] == "mocha")
|
||||
if (e.Context.Request.Form["username"] == "mocha")
|
||||
{
|
||||
if (e.Request.Form["password"] == "testing")
|
||||
if (e.Context.Request.Form["password"] == "testing")
|
||||
{
|
||||
e.Response.Redirect("~/d/home.htmld");
|
||||
e.Context.Session[tenantName + ".UserToken"] = (new Guid()).ToString("b");
|
||||
e.Context.Response.Redirect(String.Format("~/{0}/d/home.htmld", tenantName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -181,6 +183,8 @@ font-weight: lighter;
|
||||
}
|
||||
}
|
||||
|
||||
e.Context.Request.SetExtraData("TenantName", tenantName);
|
||||
|
||||
TenantHandle tenant = app.Oms.GetTenantByName(tenantName);
|
||||
if (tenant == TenantHandle.Empty)
|
||||
{
|
||||
@ -214,8 +218,13 @@ font-weight: lighter;
|
||||
// e.Server.Routes.Add(new WebRoute("/{tenant}", new RedirectWebHandler("~/{tenant}/d/home.htmld")));
|
||||
e.Server.Routes.Add(new WebRoute("/{tenant}/d/home.htmld", new WebHandler(delegate(WebContext ctx)
|
||||
{
|
||||
Console.WriteLine("req app path: " + ctx.Request.Path);
|
||||
string tenantName = ctx.Request.GetExtraData<string>("TenantName");
|
||||
if (!ctx.Session.ContainsKey(tenantName + ".UserToken"))
|
||||
{
|
||||
ctx.Response.Redirect("~/" + ctx.Request.PathVariables["tenant"] + "/d/login.htmld");
|
||||
}
|
||||
|
||||
Console.WriteLine("req app path: " + ctx.Request.Path);
|
||||
})));
|
||||
e.Server.Routes.Add(new WebRoute("/{tenant}/d/login.htmld", new RedirectWebHandler("~/madi/authgwy/{tenant}/login.htmld")));
|
||||
e.Server.Routes.Add(new WebRoute("/madi/authgwy/{tenant}/login.htmld", new LoginWebPage()));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user