aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio_22/Tango.Portal.Chat.Web/Controllers/HomeController.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio_22/Tango.Portal.Chat.Web/Controllers/HomeController.cs')
-rw-r--r--Software/Visual_Studio_22/Tango.Portal.Chat.Web/Controllers/HomeController.cs18
1 files changed, 10 insertions, 8 deletions
diff --git a/Software/Visual_Studio_22/Tango.Portal.Chat.Web/Controllers/HomeController.cs b/Software/Visual_Studio_22/Tango.Portal.Chat.Web/Controllers/HomeController.cs
index 6f1aa5dfa..8ba9fec32 100644
--- a/Software/Visual_Studio_22/Tango.Portal.Chat.Web/Controllers/HomeController.cs
+++ b/Software/Visual_Studio_22/Tango.Portal.Chat.Web/Controllers/HomeController.cs
@@ -1,6 +1,8 @@
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
using System.Text.Json;
+using Tango.Portal.Chat.Web.Models;
+using Tango.Portal.Chat.Web.Utils;
using Tango.Portal.Chat.Web.ViewModels;
namespace Tango.Portal.Chat.Web.Controllers
@@ -11,8 +13,9 @@ namespace Tango.Portal.Chat.Web.Controllers
{
if (Debugger.IsAttached)
{
+ SessionUtils.SetSessionUser(HttpContext, new Models.SessionUser() { Name = "Debug User", Email = "roy@twine-s.com", FullName = "Debug User" });
HomeViewVM v = new HomeViewVM();
- v.UserName = "debug-user";
+ v.UserName = "Debug User";
return View(v);
}
@@ -20,27 +23,26 @@ namespace Tango.Portal.Chat.Web.Controllers
if (String.IsNullOrWhiteSpace(session)) return new RedirectResult(loginUrl);
- String decryptedSession = String.Empty;
+ String json = String.Empty;
try
{
- decryptedSession = SimpleCryptoHelper.Decrypt(session);
+ json = SimpleCryptoHelper.Decrypt(session);
}
catch
{
return new RedirectResult(loginUrl);
}
- var template = new { UserName = "", Expires = DateTime.MinValue };
-
- var sessionUser = JsonSerializer.Deserialize(decryptedSession, template.GetType());
- if (sessionUser == null || (DateTime)(sessionUser as dynamic).Expires < DateTime.UtcNow)
+ var sessionUser = JsonSerializer.Deserialize<SessionUser>(json);
+ if (sessionUser == null || sessionUser.Expires < DateTime.UtcNow)
{
return new RedirectResult(loginUrl);
}
HomeViewVM vm = new HomeViewVM();
- vm.UserName = (sessionUser as dynamic).UserName;
+ vm.UserName = sessionUser.Name;
+ SessionUtils.SetSessionUser(HttpContext, sessionUser);
return View(vm);
}
}