diff options
| author | Roy Ben Shabat <roy.mail.net@gmail.com> | 2025-09-07 06:47:24 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <roy.mail.net@gmail.com> | 2025-09-07 06:47:24 +0300 |
| commit | 9ba1902ee9dbac3b3c48d735b3bbcc3ba867dd2e (patch) | |
| tree | ea0617d8dc1a4e83439a65b32e8720ab78a5c973 /Software/Visual_Studio_22/Tango.Portal.Chat.Web/Controllers/HomeController.cs | |
| parent | 2ff424e4b00ed154ae5febd1827d0d31d69c34ad (diff) | |
| download | Tango-9ba1902ee9dbac3b3c48d735b3bbcc3ba867dd2e.tar.gz Tango-9ba1902ee9dbac3b3c48d735b3bbcc3ba867dd2e.zip | |
Added seesion, chat history on ADX...
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.cs | 18 |
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); } } |
