public void CookieLockPageVars(string path, Dictionary <string, object> vars, OSHttpResponse response) { UUID random = UUID.Random(); response.AddCookie(new System.Web.HttpCookie(random.ToString())); lock (_cookieLockedVars) _cookieLockedVars[path].Add(new CookieLock { CookieUUID = random, Vars = vars }); }
public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary <string, object> requestParameters, ITranslator translator, out string response) { response = null; var vars = new Dictionary <string, object>(); string error = ""; if (requestParameters.ContainsKey("username") && requestParameters.ContainsKey("password")) { string username = requestParameters["username"].ToString(); string password = requestParameters["password"].ToString(); ILoginService loginService = webInterface.Registry.RequestModuleInterface <ILoginService>(); if (loginService.VerifyClient(UUID.Zero, username, "UserAccount", password)) { UUID sessionID = UUID.Random(); UserAccount account = webInterface.Registry.RequestModuleInterface <IUserAccountService>() .GetUserAccount(null, username); Authenticator.AddAuthentication(sessionID, account); if (account.UserLevel > 0) { Authenticator.AddAdminAuthentication(sessionID, account); } httpResponse.AddCookie(new System.Web.HttpCookie("SessionID", sessionID.ToString()) { Expires = DateTime .MinValue, Path = "" }); response = "<h3>Successfully logged in, redirecting to main page</h3>" + "<script language=\"javascript\">" + "setTimeout(function() {window.location.href = \"index.html\";}, 0);" + "</script>"; } else { response = "<h3>Failed to verify user name and password</h3>"; } return(null); } vars.Add("ErrorMessage", error); vars.Add("Login", translator.GetTranslatedString("Login")); vars.Add("UserNameText", translator.GetTranslatedString("UserName")); vars.Add("PasswordText", translator.GetTranslatedString("Password")); vars.Add("ForgotPassword", translator.GetTranslatedString("ForgotPassword")); vars.Add("Submit", translator.GetTranslatedString("Submit")); return(vars); }
public Dictionary<string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary<string, object> requestParameters, ITranslator translator, out string response) { response = null; var vars = new Dictionary<string, object>(); string error = ""; if (requestParameters.ContainsKey("username") && requestParameters.ContainsKey("password")) { string username = requestParameters["username"].ToString(); string password = requestParameters["password"].ToString(); ILoginService loginService = webInterface.Registry.RequestModuleInterface<ILoginService>(); if (loginService.VerifyClient(UUID.Zero, username, "UserAccount", password)) { UUID sessionID = UUID.Random(); UserAccount account = webInterface.Registry.RequestModuleInterface<IUserAccountService>() .GetUserAccount(null, username); Authenticator.AddAuthentication(sessionID, account); if (account.UserLevel > 0) Authenticator.AddAdminAuthentication(sessionID, account); httpResponse.AddCookie(new System.Web.HttpCookie("SessionID", sessionID.ToString()) { Expires = DateTime .MinValue, Path = "" }); response = "<h3>Successfully logged in, redirecting to main page</h3>" + "<script language=\"javascript\">" + "setTimeout(function() {window.location.href = \"index.html\";}, 0);" + "</script>"; } else response = "<h3>Failed to verify user name and password</h3>"; return null; } vars.Add("ErrorMessage", error); vars.Add("Login", translator.GetTranslatedString("Login")); vars.Add("UserNameText", translator.GetTranslatedString("UserName")); vars.Add("PasswordText", translator.GetTranslatedString("Password")); vars.Add("ForgotPassword", translator.GetTranslatedString("ForgotPassword")); vars.Add("Submit", translator.GetTranslatedString("Submit")); return vars; }
protected Dictionary <string, object> AddVarsForPage(string filename, string parentFileName, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary <string, object> requestParameters, out string response) { response = null; Dictionary <string, object> vars = new Dictionary <string, object>(); IWebInterfacePage page = GetPage(filename); if (page != null) { ITranslator translator = null; if (httpRequest.Query.ContainsKey("language")) { translator = _translators.FirstOrDefault(t => t.LanguageName == httpRequest.Query["language"].ToString()); httpResponse.AddCookie(new System.Web.HttpCookie("language", httpRequest.Query["language"].ToString())); } else if (httpRequest.Cookies.Get("language") != null) { var cookie = httpRequest.Cookies.Get("language"); translator = _translators.FirstOrDefault(t => t.LanguageName == cookie.Value); } if (translator == null) { translator = _defaultTranslator; } if (page.RequiresAuthentication) { if (!Authenticator.CheckAuthentication(httpRequest)) { return(null); } } if (page.RequiresAdminAuthentication) { if (!Authenticator.CheckAdminAuthentication(httpRequest)) { return(null); } } vars = page.Fill(this, parentFileName, httpRequest, httpResponse, requestParameters, translator, out response); return(vars); } return(null); }
public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary <string, object> requestParameters, ITranslator translator) { var vars = new Dictionary <string, object>(); string error = ""; if (requestParameters.ContainsKey("username") && requestParameters.ContainsKey("password")) { string username = requestParameters["username"].ToString(); string password = requestParameters["password"].ToString(); ILoginService loginService = webInterface.Registry.RequestModuleInterface <ILoginService>(); if (loginService.VerifyClient(UUID.Zero, username, "UserAccount", password)) { UUID sessionID = UUID.Random(); UserAccount account = webInterface.Registry.RequestModuleInterface <IUserAccountService>().GetUserAccount(null, username); Authenticator.AddAuthentication(sessionID, account.PrincipalID); if (account.UserLevel > 0) { Authenticator.AddAdminAuthentication(sessionID, account); } httpResponse.AddCookie(new System.Web.HttpCookie("SessionID", sessionID.ToString()) { Expires = DateTime.MinValue, Path = "" }); webInterface.Redirect(httpResponse, "/index.html", filename); return(vars); } else { error = "Failed to verify user name and password"; } } vars.Add("ErrorMessage", error); vars.Add("Login", translator.GetTranslatedString("Login")); vars.Add("UserNameText", translator.GetTranslatedString("UserName")); vars.Add("PasswordText", translator.GetTranslatedString("Password")); vars.Add("ForgotPassword", translator.GetTranslatedString("ForgotPassword")); vars.Add("Submit", translator.GetTranslatedString("Submit")); return(vars); }
protected bool CheckCookieLocked(string path, OSHttpRequest request, OSHttpResponse response, out Dictionary <string, object> vars) { vars = null; List <CookieLock> locks = new List <CookieLock>(); lock (_cookieLockedVars) { if (!_cookieLockedVars.TryGetValue(path, out locks)) { return(false); } } foreach (var l in locks) { foreach (var c in request.Cookies.Keys) { UUID cookieID; if (UUID.TryParse(c.ToString(), out cookieID)) { if (l.CookieUUID == cookieID) { vars = l.Vars; lock (_cookieLockedVars) _cookieLockedVars[path].Remove(l); //Attempt to nuke the cookie now response.AddCookie(new System.Web.HttpCookie(c.ToString()) { Expires = Util.UnixEpoch }); return(true); } } } } return(false); }
public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary <string, object> requestParameters, ITranslator translator, out string response) { response = null; var vars = new Dictionary <string, object> (); // homescreen login string error = ""; if (requestParameters.ContainsKey("username") && requestParameters.ContainsKey("password")) { string username = requestParameters ["username"].ToString(); string password = requestParameters ["password"].ToString(); ILoginService loginService = webInterface.Registry.RequestModuleInterface <ILoginService> (); if (loginService.VerifyClient(UUID.Zero, username, "UserAccount", password)) { UUID sessionID = UUID.Random(); UserAccount userAcct = webInterface.Registry.RequestModuleInterface <IUserAccountService> () .GetUserAccount(null, username); Authenticator.AddAuthentication(sessionID, userAcct); if (userAcct.UserLevel > 0) { Authenticator.AddAdminAuthentication(sessionID, userAcct); } httpResponse.AddCookie(new System.Web.HttpCookie("SessionID", sessionID.ToString()) { Expires = DateTime.MinValue, Path = "" }); response = "<h3>Successfully logged in</h3>" + "<script language=\"javascript\">" + "setTimeout(function() {window.location.href = \"index.html\";}, 0);" + "</script>"; } else { response = "<h3>Failed to verify user name and password</h3>"; } return(null); } // Tooltips Urls vars.Add("TooltipsWelcomeScreen", translator.GetTranslatedString("TooltipsWelcomeScreen")); vars.Add("TooltipsWorldMap", translator.GetTranslatedString("TooltipsWorldMap")); // Index Page vars.Add("HomeText", translator.GetTranslatedString("HomeText")); vars.Add("HomeTextWelcome", translator.GetTranslatedString("HomeTextWelcome")); vars.Add("HomeTextTips", translator.GetTranslatedString("HomeTextTips")); vars.Add("WelcomeScreen", translator.GetTranslatedString("WelcomeScreen")); vars.Add("WelcomeToText", translator.GetTranslatedString("WelcomeToText")); // login vars.Add("UserLogin", !Authenticator.CheckAuthentication(httpRequest)); vars.Add("ErrorMessage", error); vars.Add("Login", translator.GetTranslatedString("Login")); vars.Add("UserNameText", translator.GetTranslatedString("UserName")); vars.Add("PasswordText", translator.GetTranslatedString("Password")); vars.Add("ForgotPassword", translator.GetTranslatedString("ForgotPassword")); vars.Add("Submit", translator.GetTranslatedString("Login")); // greythane - 20160826 - do menu and setting updates var settings = webInterface.GetWebUISettings(); if (PagesMigrator.RequiresUpdate() && PagesMigrator.CheckWhetherIgnoredVersionUpdate(settings.LastPagesVersionUpdateIgnored)) { vars.Add("PagesUpdateRequired", translator.GetTranslatedString("Pages") + " " + translator.GetTranslatedString("UpdateRequired")); } else { vars.Add("PagesUpdateRequired", ""); } if (SettingsMigrator.RequiresUpdate() && SettingsMigrator.CheckWhetherIgnoredVersionUpdate(settings.LastSettingsVersionUpdateIgnored)) { vars.Add("SettingsUpdateRequired", translator.GetTranslatedString("Settings") + " " + translator.GetTranslatedString("UpdateRequired")); } else { vars.Add("SettingsUpdateRequired", ""); } vars.Add("ShowSlideshowBar", !settings.HideSlideshowBar); // user setup news inclusion if (settings.LocalFrontPage == "") { vars.Add("LocalPage", false); vars.Add("LocalFrontPage", ""); } else { vars.Add("LocalPage", true); vars.Add("LocalFrontPage", settings.LocalFrontPage); } return(vars); }
protected Dictionary<string, object> AddVarsForPage(string filename, string parentFileName, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary<string, object> requestParameters, out string response) { response = null; Dictionary<string, object> vars = new Dictionary<string, object>(); IWebInterfacePage page = GetPage(filename); if (page != null) { ITranslator translator = null; if (httpRequest.Query.ContainsKey("language")) { translator = _translators.FirstOrDefault(t => t.LanguageName == httpRequest.Query["language"].ToString()); httpResponse.AddCookie(new System.Web.HttpCookie("language", httpRequest.Query["language"].ToString())); } else if (httpRequest.Cookies.Get("language") != null) { var cookie = httpRequest.Cookies.Get("language"); translator = _translators.FirstOrDefault(t => t.LanguageName == cookie.Value); } if (translator == null) translator = _defaultTranslator; if (page.RequiresAuthentication) { if (!Authenticator.CheckAuthentication(httpRequest)) return null; } if (page.RequiresAdminAuthentication) { if (!Authenticator.CheckAdminAuthentication(httpRequest)) return null; } vars = page.Fill(this, parentFileName, httpRequest, httpResponse, requestParameters, translator, out response); return vars; } return null; }