public static SessionLogin UpsertSessionLogin(string sessionID, string userID, BaseControllerSession ttlsession, string jsessionID) { foreach (var sessionLogin in SessionLoginMap) { if (sessionLogin.sessionID == sessionID && sessionLogin.userID == userID) { sessionLogin.keepaliveDate = DateTime.Now; sessionLogin.heartbeatDate = DateTime.Now; sessionLogin.isForcedExpire = false; sessionLogin.ttlsession = ttlsession; sessionLogin.jsessionID = jsessionID; return(sessionLogin); } } SessionLogin sl = new SessionLogin(); sl.sessionID = sessionID; sl.userID = userID; sl.keepaliveDate = DateTime.Now; sl.heartbeatDate = DateTime.Now; sl.isForcedExpire = false; sl.ttlsession = ttlsession; sl.jsessionID = jsessionID; SessionLoginMap.Add(sl); return(sl); }
public static Session FromOSD(OSDMap map) { Session session; switch (map["SessionType"].AsString()) { case "SessionCaps": session = new SessionCaps(); break; case "SessionEvent": session = new SessionEvent(); break; case "SessionLogin": session = new SessionLogin(); break; case "SessionPacket": session = new SessionPacket(); break; default: return(null); } session.Deserialize(map); return(session); }
void ProxyManager_OnLoginResponse(object request, GridProxy.Direction direction) { Application.Invoke((xsender, xe) => { string loginType; if (request is Nwc.XmlRpc.XmlRpcRequest) { loginType = "Login Request"; } else { loginType = "Login Response"; } if (UDPFilterItems.ContainsKey(loginType) && UDPFilterItems[loginType].Enabled) { PacketCounter++; SessionLogin sessionLogin = new SessionLogin(request, direction, cbLoginURL.ActiveText, request.GetType().Name + " " + loginType); sessionLogin.Columns = new string[] { PacketCounter.ToString(), sessionLogin.TimeStamp.ToString("HH:mm:ss.fff"), sessionLogin.Protocol, sessionLogin.Name, sessionLogin.Length.ToString(), sessionLogin.Host, sessionLogin.ContentType }; messages.AddSession(sessionLogin); } }); }
public ActionResult Index() { if (SessionLogin.UserIsInSession()) { return(RedirectToAction("MyProfile")); } return(View()); }
protected void Session_Start() { SessionLogin user = new SessionLogin(); string myUser = HttpContext.Current.Request.LogonUserIdentity.Name; //string myUser = "******"; user.getUserPin(myUser); }
protected void Session_Start() { SessionLogin user = new SessionLogin(); //string myUser = HttpContext.Current.User.Identity.Name.ToString(); string myUser = HttpContext.Current.Request.LogonUserIdentity.Name; //string myUser = "******"; user.getUserPin(myUser); }
public ActionResult Edit(int id) { if (SessionLogin.UserIsInSession()) { ProfileViewModel profileViewModel = new ProfileViewModel(); profileViewModel.User = userClient.GetUser(id); return(View(profileViewModel)); } return(RedirectToAction("Index")); }
//Prevents the user from redirecting to a page entered in the URL public override void OnActionExecuting(ActionExecutingContext filterContext) { if (filterContext.HttpContext.Request.UrlReferrer == null || filterContext.HttpContext.Request.Url.Host != filterContext.HttpContext.Request.UrlReferrer.Host) { SessionLogin.CloseSession(); filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Quiz", action = "Index", area = "" })); } }
public ActionResult MyProfile() { if (SessionLogin.UserIsInSession()) { ProfileViewModel profileViewModel = new ProfileViewModel(); profileViewModel.User = userClient.GetUserByUsername(SessionLogin.UserName); return(View(profileViewModel)); } return(RedirectToAction("Index")); }
public ActionResult CreateLobby(int categoryId) { if (SessionLogin.UserIsInSession()) { LobbyViewModel lobbyViewModel = new LobbyViewModel(); lobbyViewModel.categoryId = categoryId; lobbyViewModel.user = userClient.GetUserByUsername(SessionLogin.UserName); return(View(lobbyViewModel)); } return(RedirectToAction("Index")); }
public SessionModule() : base("/sessions") { this.RequiresHttps(); Func <Claim, List <Permission>, bool> VerifyClaims = new Func <Claim, List <Permission>, bool>((_claim, _allowed) => { return(_allowed.Select(permission => Enum.GetName(typeof(Permission), permission)).Contains(_claim.Value)); }); Post("/", async(ctx, ct) => { SessionLogin body = this.Bind <SessionLogin>(); if (body.username == null) { return new Response { StatusCode = HttpStatusCode.BadRequest, ReasonPhrase = "username field missing." } } ; if (body.password == null) { return new Response { StatusCode = HttpStatusCode.BadRequest, ReasonPhrase = "password field missing." } } ; var token = await SessionTokenManager.ValidateUser(body.username, body.password); if (token == null) { return(HttpStatusCode.Unauthorized); } return(this.Response.AsJson(new { session_token = token })); }); Delete("/", args => { this.RequiresAuthentication(); this.RequiresClaims(c => VerifyClaims(c, new List <Permission> { Permission.ManageSelfUser })); var sessionToken = this.Request.Query.session_token?.Value;; SessionTokenManager.InvalidateToken(sessionToken); return(new Response { StatusCode = HttpStatusCode.OK }); }); }
public ActionResult Finish(int totalPoints, int lobbyId) { if (SessionLogin.UserIsInSession() && Session["Point"] != null) { quizClient.ClearTableAfterFinish(lobbyId); QuizViewModel quizViewModel = new QuizViewModel(); quizViewModel.CurrentQuizViewModel.Points = totalPoints; quizViewModel.User = userClient.GetUserByUsername(SessionLogin.UserName); quizViewModel.User.login.username = SessionLogin.UserName; return(View(quizViewModel)); } SessionLogin.CloseSession(); return(RedirectToAction("Index")); }
public BaseControllerSession getSession(bool excludePostLogin = false) { BaseControllerSession session = new BaseControllerSession(); session.isLoggedIn = false; if (!excludePostLogin) { if (Session["TTLClient"] != null) { TTLITradeWSDEV.clientLoginResponseLoginResp resp = (TTLITradeWSDEV.clientLoginResponseLoginResp)(Session["TTLClient"]); session = MakeBaseControllerSession(resp); session.isLoggedIn = true; if (Session["TTLAccount"] != null) { TTLITradeWSDEV.queryAccountDetailsResponseQueryAccountDetailsResp resp2 = (TTLITradeWSDEV.queryAccountDetailsResponseQueryAccountDetailsResp)(Session["TTLAccount"]); session.email = resp2.email; } if (Session["jsessionID"] != null) { string jsessionID = (string)Session["jsessionID"]; session.jsessionID = jsessionID; } } } if (excludePostLogin || !session.isLoggedIn) { Session["isKeptAlive"] = false; } session.fontSize = SessionLogin.getFontSizeNormal(); if (Session["fontSize"] != null) { session.fontSize = (int)Session["fontSize"]; } if (Session["isKeptAlive"] != null) { session.isKeptAlive = (bool)Session["isKeptAlive"]; } else { session.isKeptAlive = false; } return(session); }
public ActionResult JoinLobby(int lobbyId, int categoryId) { if (SessionLogin.UserIsInSession()) { LobbyViewModel lobbyViewModel = new LobbyViewModel(); lobbyViewModel.PlayerName = SessionLogin.UserName; lobbyViewModel.quizCategory = categoryClient.GetCategory(categoryId); lobbyViewModel.lobby = lobbyClient.GetLobby(lobbyId); lobbyViewModel.users = userClient.GetUsersInLobby(lobbyId); lobbyViewModel.user = userClient.GetUserByUsername(SessionLogin.UserName); return(View(lobbyViewModel)); } return(RedirectToAction("Index")); }
public ActionResult Category() { QuizViewModel quizViewModel = new QuizViewModel(); if (SessionLogin.UserIsInSession() && Session["Point"] == null) { Session["Point"] = null; quizViewModel.Categories = quizClient.GetAllCategories(); quizViewModel.loginViewModel.Username = SessionLogin.UserName; return(View(quizViewModel)); } SessionLogin.CloseSession(); return(RedirectToAction("Index")); }
public ActionResult Lobby(int categoryId) { if (SessionLogin.UserIsInSession()) { LobbyViewModel lobbyViewModel = new LobbyViewModel(); lobbyViewModel.PlayerName = SessionLogin.UserName; lobbyViewModel.lobbies = lobbyClient.GetAllLobbiesWithCategoryId(categoryId).OrderByDescending(x => x.id).ToList(); lobbyViewModel.categoryId = categoryId; lobbyViewModel.user = userClient.GetUserByUsername(SessionLogin.UserName); lobbyViewModel.IsUserInLobby = lobbyClient.IsUserInLobby(SessionLogin.UserName); lobbyViewModel.DoesUserAlreadyOwnALobby = lobbyClient.DoesUserAlreadyOwnALobby(SessionLogin.UserName); return(View(lobbyViewModel)); } return(RedirectToAction("Index")); }
public ActionResult Question(int CategoryId, int lobbyId) { if (SessionLogin.UserIsInSession()) { if (Session["currentQuizViewModel"] == null) { var quizVm = new CurrentQuizViewModel { CategoryId = CategoryId, lobbyId = lobbyId }; quizVm.User = userClient.GetUserByUsername(SessionLogin.UserName); quizVm.Questions = quizClient.GetAllQuestionsAndAnswersByCategoryId(CategoryId); quizVm.CurrentQuestion = quizVm.Questions.Skip(quizVm.ToSkip).Take(1).FirstOrDefault(); quizVm.ToSkip++; Session["currentQuizViewModel"] = quizVm; return(View(quizVm)); } else { CurrentQuizViewModel quizVm = (CurrentQuizViewModel)Session["currentQuizViewModel"]; if (quizVm.CategoryId != CategoryId) { SessionLogin.CloseSession(); return(RedirectToAction("Index")); //Hvis han prøver at skifte quiz undervejs !? } quizVm.CurrentQuestion = quizVm.Questions.Skip(quizVm.ToSkip).Take(1).FirstOrDefault(); quizVm.Points = (int)Session["Point"]; quizVm.ToSkip++; if (quizVm.CurrentQuestion == null) { Session["currentQuizViewModel"] = null; int totalPoint = (int)Session["Point"]; var user = userClient.GetUserByUsername(SessionLogin.UserName); user.point += totalPoint; userClient.AddPointsToUser(user); return(RedirectToAction("Finish", new { totalPoints = totalPoint, lobbyId = lobbyId })); } return(View(quizVm)); } } return(RedirectToAction("Index")); }
private static void CreateDependencies(string guestControllerHostUrl, string guestControllerSpoofedIpAddress, string mixApiHostUrl, string oneIdClientId, string mixClientToken, string clientVersion, ICoroutineManager coroutineManager, IKeychain keychain, AbstractLogger logger, string localStorageDirPath, string languageCode, out ISessionLogin sessionLogin, out ISessionRegister sessionRegister, out ISessionRestorer sessionRestorer, out ISessionReuser sessionReuser, out IOfflineSessionCreator offlineSessionCreator) { SystemStopwatchFactory systemStopwatchFactory = new SystemStopwatchFactory(); SystemWwwFactory wwwFactory = new SystemWwwFactory(); WwwCallFactory wwwCallFactory = new WwwCallFactory(logger, coroutineManager, systemStopwatchFactory, wwwFactory); FileSystem fileSystem = new FileSystem(); DatabaseDirectoryCreator databaseDirectoryCreator = new DatabaseDirectoryCreator(fileSystem, localStorageDirPath); DocumentCollectionFactory documentCollectionFactory = new DocumentCollectionFactory(); string sdkDatabasesDirectory = databaseDirectoryCreator.GetSdkDatabasesDirectory(); DatabaseCorruptionHandler databaseCorruptionHandler = new DatabaseCorruptionHandler(logger, fileSystem, sdkDatabasesDirectory); SystemRandom random = new SystemRandom(); SystemEpochTime epochTime = new SystemEpochTime(); Database database = new Database(keychain.LocalStorageKey, random, epochTime, databaseDirectoryCreator, documentCollectionFactory, databaseCorruptionHandler); MixWebCallQueue webCallQueue = new MixWebCallQueue(); MixSessionStartWebCallEncryptor sessionStartEncryptor = new MixSessionStartWebCallEncryptor(); MixWebCallFactoryFactory mixWebCallFactoryFactory = new MixWebCallFactoryFactory(logger, mixApiHostUrl, mixClientToken, wwwCallFactory, webCallQueue, epochTime, database); NotificationDispatcher notificationDispatcher = new NotificationDispatcher(); NotificationQueue notificationQueue = new NotificationQueue(notificationDispatcher); SessionStatus sessionStatus = new SessionStatus(isPaused: true); NoOpSessionRefresher sessionRefresher = new NoOpSessionRefresher(); JsonWebCallEncryptor webCallEncryptor = new JsonWebCallEncryptor(); IMixWebCallFactory webCallFactory = mixWebCallFactoryFactory.Create(webCallEncryptor, string.Empty, string.Empty, sessionRefresher); RsaEncryptor rsaEncryptor = new RsaEncryptor(); MixEncryptor encryptor = new MixEncryptor(); MixWebCallEncryptorFactory webCallEncryptorFactory = new MixWebCallEncryptorFactory(encryptor); SessionRefresherFactory sessionRefresherFactory = new SessionRefresherFactory(webCallQueue); MixSessionStarter mixSessionStarter = new MixSessionStarter(logger, rsaEncryptor, database, webCallEncryptorFactory, sessionStartEncryptor, mixWebCallFactoryFactory, keychain, coroutineManager, sessionRefresherFactory); IStopwatch pollCountdownStopwatch = systemStopwatchFactory.Create(); GuestControllerClientFactory guestControllerClientFactory = new GuestControllerClientFactory(wwwCallFactory, guestControllerSpoofedIpAddress, database, guestControllerHostUrl, oneIdClientId, logger); SessionFactory sessionFactory = new SessionFactory(logger, coroutineManager, pollCountdownStopwatch, epochTime, databaseCorruptionHandler, notificationQueue, notificationDispatcher, sessionStatus, mixWebCallFactoryFactory, webCallEncryptorFactory, mixSessionStarter, keychain, sessionRefresherFactory, guestControllerClientFactory, random, encryptor, fileSystem, wwwCallFactory, localStorageDirPath, clientVersion, databaseDirectoryCreator, documentCollectionFactory, database); AgeBandBuilder ageBandBuilder = new AgeBandBuilder(logger, webCallFactory); Disney.Mix.SDK.Internal.RegistrationConfigurationGetter registrationConfigurationGetter = new Disney.Mix.SDK.Internal.RegistrationConfigurationGetter(logger, guestControllerClientFactory, ageBandBuilder); LegalMarketingErrorsBuilder legalMarketingErrorsBuilder = new LegalMarketingErrorsBuilder(registrationConfigurationGetter, languageCode, epochTime); sessionLogin = new SessionLogin(logger, guestControllerClientFactory, mixSessionStarter, database, legalMarketingErrorsBuilder, sessionFactory); sessionRegister = new SessionRegister(logger, guestControllerClientFactory, database, mixSessionStarter, sessionFactory); sessionRestorer = new SessionRestorer(logger, guestControllerClientFactory, database, sessionFactory); sessionReuser = new SessionReuser(logger, database, mixSessionStarter, sessionFactory); offlineSessionCreator = new OfflineSessionCreator(logger, sessionFactory, database); }
public ActionResult LoginUser(LoginModel model) { if (ModelState.IsValid) { var dao = new UserDao(); var result = dao.Login(model.UserName, model.Password); if (result) { var user = dao.GetID(model.UserName); var session = new SessionLogin(); session.UserName = user.UserName; session.UserID = user.Id_User; Session.Add(UserSession.SessionU, session); return(RedirectToAction("Index", "home")); } else { ModelState.AddModelError("", "Đăng nhập sai ."); } } return(View("Login")); }
private static void Main(string[] args) { /*using(var fileStream = File.OpenRead(@"E:\workspace\tre\patch_05.tre")) * { * var treReader = new TREFileReader(); * var treeFile = treReader.Load(fileStream); * * var found = treeFile.InfoFiles.FirstOrDefault(cur => cur.Name.ToLower().Contains("shared_base_object.iff")); * * if (found != null) * { * var treeStream = found.Open(fileStream); * var iffReader = new IFFFileReader(); * var iffFile = iffReader.Load(treeStream); * //var root = iffFile.Root.Children.ToList(); * * var sharedObject = new SharedObjectTemplate(iffFile); * * } * }*/ //var repo = new ArchiveRepository(@"D:\SWGTrees"); //repo.LoadArchives(); //var templateRepo = new TemplateRepository //{ // ArchiveRepo = repo, //}; //var tmp = repo.LoadCrCMap("misc/object_template_crc_string_table.iff"); //var last = tmp.CRCMap.Last(); //var stringFile = repo.LoadStf("string/en/city/city.stf"); //Console.WriteLine("Enter to end;"); //Console.ReadLine(); //return; //var addrToConnect = "swgemutest"; //var connectToServerName = "swgemutest"; LogAbstraction.LogManagerFacad.ManagerImplementaiton = new NlogLogManagerImplementaion(); var graph = new ObjectGraph { ConnectTimeout = TimeSpan.FromMilliseconds(30000) }; graph.ResolveMessageFactories(); graph.ResolveFallbackMessageFactory(); graph.RegisterMessagesInFacories(); graph.RegisterMessagesInFallbackFactory(); var connector = new SessionLogin { Server = "login.swgemu.com", Password = "******", Username = "******" }; Console.WriteLine("Connecting to login server"); connector.ConnectToLoginServer(); Console.WriteLine("Logging in to login server"); connector.LoginToServer(); var serverToConnect = connector.AvailableServers.First(cur => cur.Name.Contains("Nova")); Console.WriteLine("Establishing connecting to game server: {0}:{1}", serverToConnect.ServerIP, serverToConnect.ServerPort); graph.EstablishConnection(connector.UserId, connector.SessionKey, IPAddress.Parse(serverToConnect.ServerIP), serverToConnect.ServerPort); Console.WriteLine("Logging in character"); graph.LoginCharacter(serverToConnect.Characters.First().CharacterID); Console.WriteLine("Press enter to exit"); Console.ReadLine(); }
public ActionResult Index(string locale, string category, string id) { /* * List<WebApplication2.Models.Article> articles = WebApplication2.Context.ArticleDbContext.getInstance().findArticles(); * if (articles.Count > 0) * { * log4net.ILog logger = log4net.LogManager.GetLogger("Logger"); * logger.Debug("Can fetch information from CMS"); * } */ if (locale == "zh-hk") { locale = "zh-HK"; } if (locale == "zh-cn") { locale = "zh-CN"; } if (locale == "en-us") { locale = "en-US"; } // check session if timeout if (SSO_SessionTimeout()) { SSO_ClearSession(); return(RedirectToRoute(new { controller = "Page", action = "Index", locale = locale, category = "session_timeout", })); } if (category == "session_timeout") { category = "login"; id = null; BaseViewModel vml = BaseViewModel.make(locale, category, id, Request, getSession(true)); var min = new SessionLogin().getSessionKeepaliveMinutes(); if (locale == "zh-HK" || locale == "zh-TW" || locale == "zh") { ViewBag.message = "登入時間以空置了超過" + min + "分鐘,請重新登入"; } else if (locale == "zh-CN" || locale == "cn") { ViewBag.message = "登入时间以空置了超过" + min + "分钟,请重新登入"; } else { ViewBag.message = "Session has been idled over " + min + " mins, please login again"; } if (locale != null) { Session["LANG"] = locale; } return(View(vml)); } SSO_InternalKeepAlive(); SSO_InternalHeartbeat(); var session = getSession(); if (session != null && !session.isKeptAlive) { Session["isKeptAlive"] = true; /* * if (session.hasTradingAcc) * { * return RedirectToRoute(new * { * controller = "Page", * action = "Index", * locale = locale, * category = "trading", * }); * } */ } if (category != null && category.ToLower() == "home") { return(RedirectToRoute(new { controller = "Home", action = "Index", locale = locale })); } BaseViewModel vm = BaseViewModel.make(locale, category, id, Request, session); if (!vm.category.isVisitor) { if (vm.current.session == null || vm.current.session.clientID == null) { // HOME var redirect_path = Request.Path; if (redirect_path.ToLower().Contains("/login") || redirect_path.ToLower().Contains("/session_timeout")) { redirect_path = "/" + locale; } category = "login"; id = null; BaseViewModel vml = BaseViewModel.make(locale, category, id, Request, getSession(true)); vml.redirectPack = vm; vml.constants.Add(new WebApplication2.Models.Constant { Key = "redirect", Value = redirect_path, isActive = true, }); if (locale == "zh-HK" || locale == "zh-TW" || locale == "zh") { ViewBag.message = "請登入"; } else if (locale == "zh-CN" || locale == "cn") { ViewBag.message = "请登入"; } else { ViewBag.message = "Please login"; } if (locale != null) { Session["LANG"] = locale; } return(View(vml)); } } if (!vm.category.isVisitor && !vm.category.isMember) { if (vm.current.session == null || vm.current.session.clientID == null || vm.current.session.hasTradingAcc == false) { // TRADING PAGE var redirect_path = Request.Path; if (redirect_path.ToLower().Contains("/login") || redirect_path.ToLower().Contains("/session_timeout")) { redirect_path = "/" + locale + "/page/trading"; } category = "login"; id = null; BaseViewModel vml = BaseViewModel.make(locale, category, id, Request, getSession(true)); vml.redirectPack = vm; vml.constants.Add(new WebApplication2.Models.Constant { Key = "redirect", Value = redirect_path, isActive = true, }); if (locale == "zh-HK" || locale == "zh-TW" || locale == "zh") { ViewBag.message = "請登入交易账号"; } else if (locale == "zh-CN" || locale == "cn") { ViewBag.message = "请登入交易账号"; } else { ViewBag.message = "Please login as trading account"; } if (locale != null) { Session["LANG"] = locale; } return(View(vml)); } } if (locale != null) { Session["LANG"] = locale; } return(View(vm)); }
public void SetFontSizeNormal() { Session["fontSize"] = SessionLogin.getFontSizeNormal(); }
public void SetFontSizeBig() { Session["fontSize"] = SessionLogin.getFontSizeBig(); }
public ActionResult RedirectToPage(int lobbyId) { SessionLogin.CloseSession(); quizClient.ClearTableAfterFinish(lobbyId); return(RedirectToAction("Index")); }
public ActionResult LogOff() { SessionLogin.CloseSession(); return(RedirectToAction("Index", "Quiz")); }