public Object SignOut(Boolean pManualEclockLogout) { try { SessionManager.CurrentUser = null; SessionManager.AbandonSession(); HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache); HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddSeconds(-1)); HttpContext.Current.Response.Cache.SetNoStore(); if (HttpContext.Current.Request.Cookies["breadcrumbs"] != null) { HttpCookie myCookie = new HttpCookie("breadcrumbs"); myCookie.Expires = DateTime.UtcNow.AddDays(-1d); HttpContext.Current.Response.Cookies.Add(myCookie); } var result = new { success = true, error = "" }; return(result); } catch (Exception ex) { Utility.HandleException(ex); return(new { success = false, error = "Some Error has occurred" }); } }
protected override void OnActionExecuting(ActionExecutingContext context) { base.OnActionExecuting(context); if (SessionManager.IsUserLoggedIn == false) { //Abandons the current session and redirect to Login Page SessionManager.AbandonSession(); String queryString = "ReturnURL=" + this.Request.RawUrl.Replace("%", "_"); context.Result = new RedirectResult(Resources.PAGES_DEFAULT_LOGIN_PAGE + "?" + queryString); return; } }
private void CheckIfUserIsAuthenticated(HttpActionContext actionContext) { // If Result is null, we're OK: the user is authenticated and authorized. if (actionContext.ActionArguments == null) { return; } if (SessionManager.IsUserLoggedIn == false) { //Abandons the current session and redirect to Login Page SessionManager.AbandonSession(); actionContext.Response = actionContext.Request.CreateResponse(System.Net.HttpStatusCode.NotAcceptable); return; } }
public ActionResult SignOut() { if (SessionManager.IsUserLoggedIn && SessionManager.LogsInAsOtherUser) { UserInfoRepository repo = new UserInfoRepository(); repo.ValidateUser(SessionManager.ActualUserLoginID, "", "", true, false); SessionManager.ActualUserUserID = 0; SessionManager.LogsInAsOtherUser = false; SessionManager.ActualUserLoginID = ""; return(RedirectToAction("Index", "Home")); } else { SessionManager.AbandonSession(); return(RedirectToAction("Index")); } }
static void Main() { Logger.CurrentLevel = DefaultLogLevel; _accClient = new AccDataAggregator(host: "office-pc"); _connection = _accClient.Start(); _sessionManager = new SessionManager(); _sessionManager.TimedPhaseStarted += (sender, args) => { }; _sessionManager.SessionStarted += (sender, args) => { _connection.Send(new TrackDataRequest()); }; _connection.MessageReceived += (sender, message) => { if (message is RealTimeUpdateResponse realtimeUpdate) { _sessionManager.UpdateSessionBasics(realtimeUpdate.SessionType, realtimeUpdate.Phase); _sessionManager.UpdateSessionDetails(realtimeUpdate); } if (message is RealTimeCarUpdateResponse realtimeCarUpdate) { _sessionManager.UpdateCarDetails( realtimeCarUpdate.CarIndex, realtimeCarUpdate.Position, realtimeCarUpdate.CarLocation, realtimeCarUpdate.Laps, realtimeCarUpdate.CurrentLap, realtimeCarUpdate.LastLap, realtimeCarUpdate.Delta ); } if (message is TrackDataResponse trackResponse) { _sessionManager.SetTrack(trackResponse.TrackName); // Invert this so the SessionManager indicates it is ready for the entry list _connection.Send(new EntryListRequest()); } if (message is EntryListCarResponse carResponse) { _sessionManager.SetCar( carResponse.CarId, carResponse.CarModel, ( carResponse.Drivers.First().FirstName, carResponse.Drivers.First().LastName ) ); } if (message is BroadcastingEventResponse broadcastingEvent) { if (broadcastingEvent.MessageType == BroadcastingEventType.LapCompleted) { //TODO: Ask session manager to update car //_sessionManager.SendDetails(); } } if (message is EntryListResponse entryListResponse) { _sessionManager.VerifyCarList(entryListResponse.CarIndices.Select(Convert.ToInt32).ToArray()); } }; _connection.ConnectionLost += (sender, args) => { _sessionManager.AbandonSession(); Logger.Log("Session abandoned"); }; // Entry list is polled to check for disconnections var entryListUpdateTimer = new System.Timers.Timer(5000); entryListUpdateTimer.Elapsed += (args, sender) => { if (_connection.Connected) { _connection.Send(new EntryListRequest()); } }; entryListUpdateTimer.Start(); while (true) { var key = Console.ReadKey().Key; if (key == ConsoleKey.Q) { break; } if (key == ConsoleKey.Delete) { Console.Clear(); } if (key == ConsoleKey.C) { foreach (var carDetails in _sessionManager.GetAllCars().OrderBy(c => c.Disconnected).ThenBy(c => c.Position)) { var position = carDetails.Disconnected ? "DIS" : carDetails.Position.Value.ToString(); Logger.Log($"{position}. [{carDetails.Location.GetDescription()}] {carDetails.CarModel.GetDescription()} {carDetails.CurrentDriver} {carDetails.LapCount} Laps {carDetails.Delta}"); } } if (key == ConsoleKey.T) { _connection.Send(new TrackDataRequest()); } if (key == ConsoleKey.E) { _connection.Send(new EntryListRequest()); } if (key == ConsoleKey.V) { Logger.CurrentLevel = Logger.CurrentLevel == DefaultLogLevel ? LogLevel.Verbose : DefaultLogLevel; } } _connection.Stop(); }