public static string HiddenSortColFields() { string html = new Forms.HiddenField("ColSortField") + ""; html += new Forms.HiddenField("ColSortDesc"); //JC Added 20150319 Losing params when filtering. var keys = Web.Request.QueryString.AllKeys; string[] exclusions = { "PageNum", "ColSortField", "ColSortDesc", "Search" }; // dont know if this needs tweaking. foreach (var key in keys) { if (exclusions.Contains(key)) { //skip over normal keys } else { html += new Forms.HiddenField(key, Web.Request[key]); } } return(html); }
void AccountSecurity_Show(object sender, EventArgs e) { template.SetTemplate("account_security.html"); Save(new EventHandler(AccountSecurity_Save)); if (core.Http.Query["mode"] == "enrole_phone" && (!LoggedInMember.UserInfo.TwoFactorAuthVerified)) { template.SetTemplate("account_security_twofactor.html"); AuthoriseRequestSid(); } else if (core.Http.Query["mode"] == "enrole_authenticator" && (!LoggedInMember.UserInfo.TwoFactorAuthVerified)) { template.SetTemplate("account_security_twofactor.html"); AuthoriseRequestSid(); Authenticator authenticator = new Authenticator(); string key = authenticator.GenerateKey(); Dictionary<string, string> args = new Dictionary<string, string>(); args.Add("mode", "qr_code"); args.Add("secret", key); string qrCode = core.Hyperlink.AppendSid(BuildUri("security", args), true); BoxSocial.Forms.Image qrCodeImage = new Forms.Image("qr_code", qrCode); BoxSocial.Forms.TextBox verifyTextBox = new Forms.TextBox("verify"); BoxSocial.Forms.HiddenField keyHiddenField = new Forms.HiddenField("key"); keyHiddenField.Value = key; template.Parse("S_ENROLE_AUTHENTICATOR", "TRUE"); template.Parse("I_QR_CODE", qrCodeImage); template.Parse("S_KEY", keyHiddenField); template.Parse("S_VERIFY", verifyTextBox); template.Parse("USERNAME", LoggedInMember.UserName); LoggedInMember.UserInfo.TwoFactorAuthKey = key; LoggedInMember.UserInfo.Update(); } else if (LoggedInMember.UserInfo.TwoFactorAuthVerified) { template.Parse("S_ENABLED", "TRUE"); template.Parse("U_DISABLE", core.Hyperlink.AppendSid(BuildUri("security", "disable"), true)); } else { template.Parse("S_DISABLED", "TRUE"); template.Parse("U_ENABLE", core.Hyperlink.AppendSid(BuildUri("security", "enrole_phone"), true)); } // Show all active sessions SelectQuery query = SessionKey.GetSelectQueryStub(core, typeof(SessionKey)); query.AddCondition(new DataField(typeof(SessionKey), "user_id"), LoggedInMember.Id); query.AddSort(SortOrder.Descending, "key_last_visit_ut"); System.Data.Common.DbDataReader sessionsReader = db.ReaderQuery(query); while (sessionsReader.Read()) { SessionKey sessionKey = new SessionKey(core, sessionsReader); VariableCollection sessionsVariableCollection = template.CreateChild("sessions_list"); sessionsVariableCollection.Parse("IP", sessionKey.Ip); sessionsVariableCollection.Parse("TIME", core.Tz.DateTimeToString(sessionKey.GetVisit(core.Tz))); sessionsVariableCollection.Parse("BROWSER_STRING", sessionKey.BrowserString); } sessionsReader.Close(); sessionsReader.Dispose(); }