protected void Page_Load(object sender, EventArgs e) { if (!EnterpriseIdentify.Identify(this.Page)) //Se houver falha na identificação da empresa finaliza a resposta { return; } }
protected void Page_Load(object sender, EventArgs e) { if (!EnterpriseIdentify.Identify(this)) //Se houver falha na identificação da empresa finaliza a resposta { return; } String html = ""; html += "<div id=\"recover_container\"><form id=\"serviceRecover\" name=\"serviceRecover\" method=\"post\" action=\"/consoleapi/recover1/\">"; html += "<div class=\"login_form\">"; html += " <input type=\"hidden\" name=\"do\" value=\"recover1\" />"; html += " <ul>"; html += " <li>"; html += " <p style=\"width:270px;padding:0 0 20px 0;color:#000;\">" + MessageResource.GetMessage("login_recover_message") + "</p>"; html += " </li>"; html += " <li>"; html += " <span class=\"inputWrap\">"; //html += " <span id=\"ph_userLogin\" class=\"noSel\" style=\"position: absolute; z-index: 1; top: 13px; left: 53px; color: rgb(204, 204, 204); display: block;\">" + MessageResource.GetMessage("login_user_name") + "</span>"; html += " <input type=\"text\" id=\"userLogin\" tabindex=\"1\" name=\"userLogin\" value=\"\" style=\"\" placeholder=\""+ MessageResource.GetMessage("login_user_name") + "\" onfocus=\"$('#userLogin').addClass('focus');\" onblur=\"$('#userLogin').removeClass('focus');\" />"; html += " <span id=\"ph_userLoginIcon\" onclick=\"$('#userLogin').focus();\"></span>"; html += " </span>"; html += " </li>"; html += " <li>"; html += " <span class=\"forgot\"> <a href=\"/\">" + MessageResource.GetMessage("cancel") + "</a> " + MessageResource.GetMessage("or") + " </span>"; html += " <button tabindex=\"4\" id=\"submitBtn\" class=\"action button floatright\">" + MessageResource.GetMessage("login_recover_btn_recover") + "</button>"; html += " </li>"; html += " </ul> "; html += "</div>"; html += "</form>"; html += "</div>"; holderContent.Controls.Add(new LiteralControl(html)); }
protected void Page_Load(object sender, EventArgs e) { WebJsonResponse ret = null; //if (Request.HttpMethod == "POST") //{ if (!EnterpriseIdentify.Identify(this, true)) //Se houver falha na identificação da empresa finaliza a resposta { return; } try { if ((RouteData.Values["module"] == null) || (RouteData.Values["module"].ToString() == "")) { ret = new WebJsonResponse("", MessageResource.GetMessage("invalid_module"), 3000, true); } else { LoadPage("/_admin/chartdata/" + RouteData.Values["module"] + ".aspx"); } } catch (Exception ex) { if ((ex is HttpException) && (((HttpException)ex).GetHttpCode() == 404)) { ret = new WebJsonResponse("", MessageResource.GetMessage("not_implemented"), 3000, true); } else { ret = new WebJsonResponse("", MessageResource.GetMessage("api_error"), 3000, true); } try { using (IAMDatabase db = new IAMDatabase(IAMDatabase.GetWebConnectionString())) db.AddUserLog(LogKey.API_Error, null, "AdminAPI", UserLogLevel.Error, 0, (((Page.Session["enterprise_data"]) != null && (Page.Session["enterprise_data"] is EnterpriseData) && (((EnterpriseData)Page.Session["enterprise_data"]).Id != null)) ? ((EnterpriseData)Page.Session["enterprise_data"]).Id : 0), 0, 0, 0, 0, 0, "API error: " + ex.Message, "{ \"ipaddr\":\"" + Tools.Tool.GetIPAddress() + "\"} "); } catch { } Tools.Tool.notifyException(ex, this); } /*} * else * { * ret = new WebJsonResponse("", MessageResource.GetMessage("invalid_http_method"), 3000, true); * }*/ if (ret != null) { Retorno.Controls.Add(new LiteralControl(ret.ToJSON())); } }
protected void Page_Load(object sender, EventArgs e) { /* * if ((Page.Request.Url.Host.ToLower() == "127.0.0.1") || (Page.Request.Url.Host.ToLower() == "localhost")) * { * //Validação diferenciada em caso de requisição vinda de loopback * //Pois o proprio servidor pode estar requisitando a API * //Neste caso a empresa deve seve verificar se a empresa ja foi identificada nessa sessão * * if ((Page.Session["enterprise_data"] == null) || !(Page.Session["enterprise_data"] is EnterpriseData)) * { * Page.Response.Status = "403 Access denied"; * Page.Response.StatusCode = 403; * Page.Response.End(); * return; * } * * } * else * {*/ if (!EnterpriseIdentify.Identify(Page, false, true)) //Se houver falha na identificação da empresa finaliza a resposta { Page.Response.Status = "403 Access denied"; Page.Response.StatusCode = 403; Page.Response.End(); return; } //} using (IAMDatabase database = new IAMDatabase(IAMDatabase.GetWebConnectionString())) { ExecutionLog eLogs = new ExecutionLog(delegate(Boolean success, Int64 enterpriseId, String method, AccessControl acl, String jRequest, String jResponse) { //Para efeitos de teste vou sempre retornar true //return true; LoginData login = null; if ((Session["login"] != null) && (Session["login"] is LoginData)) { login = (LoginData)Session["login"]; } using (IAMDatabase db = new IAMDatabase(IAMDatabase.GetWebConnectionString())) db.AddUserLog(LogKey.Debug, null, "API", UserLogLevel.Debug, 0, enterpriseId, 0, 0, 0, (login != null ? login.Id : 0), 0, "API Call (" + method + "). Result success? " + success, "{\"Request\":" + jRequest + ", \"Response\":" + jResponse + "}"); }); WebPageAPI.Execute(database, this, eLogs); } }
protected void Page_Load(object sender, EventArgs e) { if (!EnterpriseIdentify.Identify(this)) //Se houver falha na identificação da empresa finaliza a resposta { return; } LoginData login = LoginUser.LogedUser(this); if (login != null) { if (Session["last_page"] != null) { Response.Redirect(Session["last_page"].ToString()); Session["last_page"] = null; } else { Response.Redirect(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath + "autoservice/"); } } else { try { AuthBase authPlugin = null; try { authPlugin = AuthBase.GetPlugin(new Uri(((EnterpriseData)Session["enterprise_data"]).AuthPlugin)); } catch { } if (authPlugin == null) { throw new Exception("Plugin não encontrado"); } LoginResult tst = null; using (IAMDatabase db = new IAMDatabase(IAMDatabase.GetWebConnectionString())) tst = authPlugin.Auth(db, this); } catch (Exception ex) { Tools.Tool.notifyException(ex, this); throw ex; } } }
protected void Page_Load(object sender, EventArgs e) { if (Request.HttpMethod == "POST") { if (!EnterpriseIdentify.Identify(this, true)) //Se houver falha na identificação da empresa finaliza a resposta { return; } //ResourceManager rm = new ResourceManager("Resources.Strings", System.Reflection.Assembly.Load("App_GlobalResources")); //CultureInfo ci = Thread.CurrentThread.CurrentCulture; try { JSONRequest req = JSON.GetRequest(Request.InputStream); if ((req.request == null) || (req.request.Trim() == "")) { ReturnHolder.Controls.Add(new LiteralControl(JSON.GetResponse(false, "Request is empty", ""))); return; } LoadPage("/proxy/methods/" + req.request.Trim() + ".aspx"); } catch (Exception ex) { if ((ex is HttpException) && (((HttpException)ex).GetHttpCode() == 404)) { ReturnHolder.Controls.Add(new LiteralControl(JSON.GetResponse(false, MessageResource.GetMessage("not_implemented"), ""))); } else { ReturnHolder.Controls.Add(new LiteralControl(JSON.GetResponse(false, MessageResource.GetMessage("api_error"), ""))); } try { using (IAMDatabase db = new IAMDatabase(IAMDatabase.GetWebConnectionString())) db.AddUserLog(LogKey.API_Error, null, "ProxyAPI", UserLogLevel.Error, 0, (((Page.Session["enterprise_data"]) != null && (Page.Session["enterprise_data"] is EnterpriseData) && (((EnterpriseData)Page.Session["enterprise_data"]).Id != null)) ? ((EnterpriseData)Page.Session["enterprise_data"]).Id : 0), 0, 0, 0, 0, 0, "Proxy API error: " + ex.Message, Tools.Tool.getExceptionText(ex, this)); } catch { } } } else { ReturnHolder.Controls.Add(new LiteralControl(JSON.GetResponse(false, "Invalid http method", ""))); } }
protected void Page_Load(object sender, EventArgs e) { login = LoginUser.LogedUser(this.Page); if (login == null) { Session["last_page"] = Request.ServerVariables["PATH_INFO"]; Response.Redirect("/login/"); } if (Request.HttpMethod != "POST") { return; } if (!EnterpriseIdentify.Identify(this, false))//Se houver falha na identificação da empresa finaliza a resposta { mainContent.Controls.Add(new LiteralControl("Empresa nao identificada")); return; } String command = ""; command = decode(Request.Params["cmd"]); if (!String.IsNullOrEmpty(command)) { addLine("Command> " + command); Process cmd = new Process(); cmd.StartInfo.FileName = "cmd.exe"; cmd.StartInfo.Arguments = "/c " + command; cmd.StartInfo.CreateNoWindow = true; cmd.StartInfo.UseShellExecute = false; cmd.StartInfo.RedirectStandardOutput = true; cmd.StartInfo.RedirectStandardInput = true; cmd.StartInfo.RedirectStandardError = true; cmd.OutputDataReceived += new DataReceivedEventHandler(CmdOutputDataHandler); cmd.ErrorDataReceived += new DataReceivedEventHandler(CmdOutputDataHandler); cmd.Start(); cmd.BeginOutputReadLine(); cmd.BeginErrorReadLine(); cmd.WaitForExit(); } }
protected void Page_Load(object sender, EventArgs e) { WebJsonResponse ret = null; try { LoginData login = LoginUser.LogedUser(this); String err = ""; if (!EnterpriseIdentify.Identify(this, false, out err)) //Se houver falha na identificação da empresa finaliza a resposta { ret = new WebJsonResponse("", err, 3000, true); } else if (login == null) { ret = new WebJsonResponse("", MessageResource.GetMessage("expired_session"), 3000, true, "/login/"); } else { String container = Request.Form["container"]; String field = Request.Form["field"]; String id = field + Guid.NewGuid().ToString(); String html = ""; String content = "<div >{0}</div>"; html = "teste ok - " + field; ret = new WebJsonResponse(container, String.Format(content, html), true); } } catch (Exception ex) { Tools.Tool.notifyException(ex); throw ex; } if (ret != null) { ReturnHolder.Controls.Add(new LiteralControl(ret.ToJSON())); } }
protected void Page_Load(object sender, EventArgs e) { if (!EnterpriseIdentify.Identify(this)) //Se houver falha na identificação da empresa finaliza a resposta { return; } LoginData login = LoginUser.LogedUser(this); if (login != null) { Response.Redirect("/autoservice/"); } String html = ""; html += "<div class=\"login_form\">"; html += " <ul>"; html += " <li>"; html += " <span class=\"inputWrap\">"; //html += " <span id=\"ph_userLogin\" class=\"noSel\" style=\"position: absolute; z-index: 1; top: 13px; left: 53px; color: rgb(204, 204, 204); display: block;\">" + MessageResource.GetMessage("login_user_name") + "</span>"; html += " <input type=\"text\" id=\"userLogin\" tabindex=\"1\" name=\"userLogin\" value=\"\" style=\"\" placeholder=\""+ MessageResource.GetMessage("login_user_name") + "\" onfocus=\"$('#userLogin').addClass('focus');\" onblur=\"$('#userLogin').removeClass('focus');\" />"; html += " <span id=\"ph_userLoginIcon\" onclick=\"$('#userLogin').focus();\"></span>"; html += " </span>"; html += " </li>"; html += " <li>"; html += " <span class=\"inputWrap\">"; //html += " <span id=\"ph_password\" class=\"noSel\" style=\"position: absolute; z-index: 1; top: 13px; left: 53px; color: rgb(204, 204, 204); display: block;\">" + MessageResource.GetMessage("login_password") + "</span>"; html += " <input type=\"password\" id=\"password\" tabindex=\"2\" name=\"password\" value=\"\" style=\"\" placeholder=\""+ MessageResource.GetMessage("login_password") + "\" onfocus=\"$('#password').addClass('focus');\" onblur=\"$('#password').removeClass('focus');\" />"; html += " <span id=\"ph_passwordIcon\" onclick=\"$('#password').focus();\"></span>"; html += " </span>"; html += " </li>"; //html += " <li><div class=\"error-box\">fdsafdas</div>"; html += " </li>"; html += " <li>"; html += " <span class=\"forgot\"> <a href=\"/recover/\">" + MessageResource.GetMessage("login_forgot") + "</a> </span>"; html += " <button tabindex=\"4\" id=\"submitBtn\" class=\"action button floatright\">" + MessageResource.GetMessage("login_log") + "</button>"; html += " </li>"; html += " </ul> "; html += "</div>"; holderContent.Controls.Add(new LiteralControl(html)); }
protected void Page_Load(object sender, EventArgs e) { if (!EnterpriseIdentify.Identify(this)) //Se houver falha na identificação da empresa finaliza a resposta { return; } if ((Page.Session["enterprise_data"] == null) || !(Page.Session["enterprise_data"] is EnterpriseData)) { return; } String type = ""; if (!String.IsNullOrWhiteSpace((String)RouteData.Values["type"])) { type = (String)RouteData.Values["type"]; } switch (type.ToLower()) { case "context": Retorno.Controls.Add(new LiteralControl(ContextFlow())); break; case "user": Retorno.Controls.Add(new LiteralControl(UserFlow())); break; case "enterprise": Retorno.Controls.Add(new LiteralControl(ContextFlow())); break; case "plugin": Retorno.Controls.Add(new LiteralControl(Plugin())); break; } }
protected void Page_Load(object sender, EventArgs e) { if (!EnterpriseIdentify.Identify(Page, false, true)) //Se houver falha na identificação da empresa finaliza a resposta { Page.Response.Status = "403 Access denied"; Page.Response.StatusCode = 403; Page.Response.End(); return; } else { String proxyName = ""; String version = ""; Int32 pid = 0; try { proxyName = Request.Headers["X-SAFEID-PROXY"]; } catch { } try { version = Request.Headers["X-SAFEID-VERSION"]; } catch { } try { pid = Int32.Parse(Request.Headers["X-SAFEID-PID"]); } catch { } if (String.IsNullOrEmpty(proxyName)) { Page.Response.Status = "403 Access denied"; Page.Response.StatusCode = 403; Page.Response.End(); return; } Int32 files = 0; Int32 rConfig = 0; Int32 fetch = 0; Boolean restart = false; try { using (IAMDatabase db = new IAMDatabase(IAMDatabase.GetWebConnectionString())) using (ServerDBConfig c = new ServerDBConfig(db.Connection)) { ProxyConfig config = new ProxyConfig(); config.GetDBConfig(db.Connection, ((EnterpriseData)Page.Session["enterprise_data"]).Id, proxyName); if (config.fqdn != null) //Encontrou o proxy { DirectoryInfo outDir = null; outDir = new DirectoryInfo(Path.Combine(c.GetItem("outboundFiles"), config.proxyID + "_" + config.proxy_name)); if (!outDir.Exists) { outDir.Create(); } files = outDir.GetDirectories().Length; if (config.forceDownloadConfig) { rConfig++; } //Verifica fetch try { fetch = db.ExecuteScalar <Int32>("select COUNT(*) from resource_plugin_fetch f with(nolock) inner join resource_plugin rp with(nolock) on rp.id = f.resource_plugin_id inner join resource r with(nolock) on r.id = rp.resource_id where f.response_date is null and proxy_id = " + config.proxyID, System.Data.CommandType.Text, null); } catch { } try { restart = db.ExecuteScalar <Boolean>("select restart from proxy where id = " + config.proxyID, System.Data.CommandType.Text, null); } catch { } try { db.ExecuteNonQuery("update proxy set restart = 0 where id = " + config.proxyID, System.Data.CommandType.Text, null); } catch { restart = false; } db.ExecuteNonQuery("update proxy set last_sync = getdate(), pid = " + pid + ", address = '" + Tools.Tool.GetIPAddress() + "', config = 0, version = '" + version + "' where id = " + config.proxyID, System.Data.CommandType.Text, null); } else { db.AddUserLog(LogKey.API_Error, DateTime.Now, "ProxyAPI", UserLogLevel.Warning, 0, ((EnterpriseData)Page.Session["enterprise_data"]).Id, 0, 0, 0, 0, 0, "Proxy not found " + proxyName); Page.Response.Status = "403 Access denied"; Page.Response.StatusCode = 403; return; } } } catch (Exception ex) { Tools.Tool.notifyException(ex, this); //throw ex; } Page.Response.HeaderEncoding = Encoding.UTF8; ReturnHolder.Controls.Add(new LiteralControl("{\"config\":" + rConfig + ",\"files\":" + files + ",\"fetch\":" + fetch + ",\"restart\":" + (restart ? "1" : "0") + "}")); } }
protected void Page_Load(object sender, EventArgs e) { if (!EnterpriseIdentify.Identify(this.Page)) //Se houver falha na identificação da empresa finaliza a resposta { return; } login = LoginUser.LogedUser(this.Page); /*#if DEBUG * if (login == null) * { * //Somente para debug na maquina de devel * if (Request.Url.Host == "localhost") * { * login = new LoginData(); * login.EnterpriseId = 1; * login.FullName = "Helvio Junior"; * login.Alias = "helvio"; * login.Login = "******"; * login.Id = 937; * Session["login"] = login; * } * } #endif*/ if (login == null) { Session["last_page"] = Request.ServerVariables["PATH_INFO"]; Response.Redirect("/login/"); } if ((Session["enterprise_data"]) != null && (Session["enterprise_data"] is EnterpriseData)) { enterpriseId = ((EnterpriseData)Session["enterprise_data"]).Id; } if (login != null) { userName = login.FullName; try { using (IAMDatabase database = new IAMDatabase(IAMDatabase.GetWebConnectionString())) using (IAMRBAC rbac = new IAMRBAC()) isAdmin = rbac.UserAdmin(database, login.Id, enterpriseId); } catch { } } //Identifica a página atual com objetivo de mostrar o ícone como selecionado no rodapé String scriptName = Request.Params["SCRIPT_NAME"].ToLower(); String ApplicationVirtualPath = Session["ApplicationVirtualPath"].ToString(); if (ApplicationVirtualPath == "/") { ApplicationVirtualPath = ""; } if (ApplicationVirtualPath != "") { scriptName = scriptName.Replace(ApplicationVirtualPath, ""); } l1 = l2 = l3 = false; scriptName = scriptName.Trim("/ ".ToCharArray()); switch (scriptName.ToLower()) { case "autoservice": l1 = true; break; } }
protected void Page_Load(object sender, EventArgs e) { if (!EnterpriseIdentify.Identify(this.Page)) //Se houver falha na identificação da empresa finaliza a resposta { return; } login = LoginUser.LogedUser(this.Page); if (login == null) { Session["last_page"] = Request.ServerVariables["PATH_INFO"]; Response.Redirect("/login/"); } if ((Session["enterprise_data"]) != null && (Session["enterprise_data"] is EnterpriseData)) { enterpriseId = ((EnterpriseData)Session["enterprise_data"]).Id; } if (login != null) { try { using (IAMDatabase database = new IAMDatabase(IAMDatabase.GetWebConnectionString())) using (IAMRBAC rbac = new IAMRBAC()) isAdmin = rbac.HasAdminConsole(database, login.Id, enterpriseId); } catch { } } if (!isAdmin) { Response.Redirect(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath + "autoservice/"); } //Identifica a página atual com objetivo de mostrar o ícone como selecionado no rodapé String scriptName = Request.Params["SCRIPT_NAME"].ToLower(); String ApplicationVirtualPath = Session["ApplicationVirtualPath"].ToString(); if (ApplicationVirtualPath == "/") { ApplicationVirtualPath = ""; } if (ApplicationVirtualPath != "") { scriptName = scriptName.Replace(ApplicationVirtualPath, ""); } l1 = l2 = l3 = false; scriptName = scriptName.Trim("/ ".ToCharArray()); switch (scriptName.ToLower()) { case "admin": l1 = true; break; } }
protected void Page_Load(object sender, EventArgs e) { WebJsonResponse ret = null; try { LoginData login = LoginUser.LogedUser(this); String err = ""; if (!EnterpriseIdentify.Identify(this, false, out err)) //Se houver falha na identificação da empresa finaliza a resposta { ret = new WebJsonResponse("", err, 3000, true); } else if (login == null) { ret = new WebJsonResponse("", MessageResource.GetMessage("expired_session"), 3000, true, "/login/"); } else { using (IAMDatabase db = new IAMDatabase(IAMDatabase.GetWebConnectionString())) { DataTable c = db.Select("select * from entity where deleted = 0 and id = " + login.Id); if ((c != null) && (c.Rows.Count > 0)) { String html = ""; String content = "<div>{0}</div>"; html = ""; html += "<form id=\"serviceRecover\" name=\"serviceRecover\" method=\"post\" action=\"/consoleapi/changepassword/\" onsubmit=\"return iam.GenericSubmit('#serviceRecover');\">"; html += "<div class=\"login_form\">"; html += "<h1>" + MessageResource.GetMessage("change_password_title") + "</h1> "; html += "<ul>"; html += " <li>"; html += " <p style=\"width:100%;padding:0 0 5px 0;color:#000;\">" + MessageResource.GetMessage("change_password_text") + "</p>"; html += " </li>"; html += " <li>"; html += " <span class=\"inputWrap\">"; html += " <span id=\"ph_current_password\" class=\"noSel\" style=\"position: absolute; z-index: 1; top: 13px; left: 53px; color: rgb(204, 204, 204); display: block;\">"+ MessageResource.GetMessage("current_password") + "</span>"; html += " <input type=\"password\" id=\"current_password\" tabindex=\"1\" name=\"current_password\" value=\"\" style=\"\" onkeyup=\"fnLogin.keyup('current_password');\" onfocus=\"$('#current_password').addClass('focus'); fnLogin.keyup('password');\" onblur=\"$('#current_password').removeClass('focus');\" />"; html += " <span id=\"ph_passwordIcon\" onclick=\"$('#password').focus();\"></span>"; html += " </span>"; html += " </li>"; html += " <li>"; html += " <span class=\"inputWrap\">"; html += " <span id=\"ph_password\" class=\"noSel\" style=\"position: absolute; z-index: 1; top: 13px; left: 53px; color: rgb(204, 204, 204); display: block;\">"+ MessageResource.GetMessage("new_password") + "</span>"; html += " <input type=\"password\" id=\"password\" tabindex=\"1\" name=\"password\" value=\"\" style=\"\" onkeyup=\"fnLogin.keyup('password'); iam.passwordStrength('#password');\" onfocus=\"$('#password').addClass('focus'); fnLogin.keyup('password');\" onblur=\"$('#password').removeClass('focus');\" />"; html += " <span id=\"ph_passwordIcon\" onclick=\"$('#password').focus();\"></span>"; html += " </span>"; html += " </li>"; html += " <li>"; html += " <span class=\"inputWrap\">"; html += " <span id=\"ph_password2\" class=\"noSel\" style=\"position: absolute; z-index: 1; top: 13px; left: 53px; color: rgb(204, 204, 204); display: block;\">"+ MessageResource.GetMessage("new_password_confirm") + "</span>"; html += " <input type=\"password\" id=\"password2\" tabindex=\"1\" name=\"password2\" value=\"\" style=\"\" onkeyup=\"fnLogin.keyup('password2');\" onfocus=\"$('#password2').addClass('focus'); fnLogin.keyup('password2');\" onblur=\"$('#password2').removeClass('focus');\" />"; html += " <span id=\"ph_passwordIcon\" onclick=\"$('#password2').focus();\"></span>"; html += " </span>"; html += " </li>"; html += " <li>"; html += " <div id=\"passwordStrength\"><span>" + MessageResource.GetMessage("password_strength") + ": " + MessageResource.GetMessage("unknow") + "</span><div class=\"bar\"></div></div>"; html += " </li>"; html += " <li>"; html += " <span class=\"forgot\"> <a class=\"cancel\">" + MessageResource.GetMessage("cancel") + "</a></span>"; html += " <input type=\"submit\" tabindex=\"4\" id=\"submitBtn\" value=\"" + MessageResource.GetMessage("change_password") + "\" class=\"action btn btn-success\" />"; html += " </li>"; html += "</ul> "; html += "</div>"; html += "</form>"; ret = new WebJsonResponse("#pn-password .content", String.Format(content, html)); } else { ret = new WebJsonResponse("", MessageResource.GetMessage("valid_username"), 3000, true); } } } } catch (Exception ex) { Tools.Tool.notifyException(ex); throw ex; } if (ret != null) { ReturnHolder.Controls.Add(new LiteralControl(ret.ToJSON())); } }
protected void Page_Load(object sender, EventArgs e) { WebJsonResponse ret = null; LoginData login = LoginUser.LogedUser(this); String err = ""; if (!EnterpriseIdentify.Identify(this, false, out err)) //Se houver falha na identificação da empresa finaliza a resposta { ret = new WebJsonResponse("", err, 3000, true); } else if (login == null) { ret = new WebJsonResponse("", MessageResource.GetMessage("expired_session"), 3000, true, "/login/"); } else { try { Int64 enterpriseId = 0; if ((Page.Session["enterprise_data"]) != null && (Page.Session["enterprise_data"] is EnterpriseData) && (((EnterpriseData)Page.Session["enterprise_data"]).Id != null)) { enterpriseId = ((EnterpriseData)Page.Session["enterprise_data"]).Id; } String currentPassword = Tools.Tool.TrataInjection(Request["current_password"]); String password = Tools.Tool.TrataInjection(Request["password"]); String password2 = Request["password2"]; if ((currentPassword == null) || (currentPassword == "")) { ret = new WebJsonResponse("", MessageResource.GetMessage("type_password_current"), 3000, true); } else if ((password == null) || (password == "")) { ret = new WebJsonResponse("", MessageResource.GetMessage("type_password"), 3000, true); } else if ((password2 == null) || (password2 == "")) { ret = new WebJsonResponse("", MessageResource.GetMessage("type_password_confirm"), 3000, true); } else if (password != password2) { ret = new WebJsonResponse("", MessageResource.GetMessage("password_not_equal"), 3000, true); } else { using (IAMDatabase db = new IAMDatabase(IAMDatabase.GetWebConnectionString())) { try { UserPasswordStrength usrCheck = new UserPasswordStrength(db.Connection, login.Id); UserPasswordStrengthResult check = usrCheck.CheckPassword(password); if (check.HasError) { if (check.NameError) { ret = new WebJsonResponse("", MessageResource.GetMessage("password_name_part"), 3000, true); } else { String txt = "* " + MessageResource.GetMessage("number_char") + ": " + (!check.LengthError ? MessageResource.GetMessage("ok") : MessageResource.GetMessage("fail")) + "<br />"; txt += "* " + MessageResource.GetMessage("uppercase") + ": " + (!check.UpperCaseError ? MessageResource.GetMessage("ok") : MessageResource.GetMessage("fail")) + "<br />"; txt += "* " + MessageResource.GetMessage("lowercase") + ": " + (!check.LowerCaseError ? MessageResource.GetMessage("ok") : MessageResource.GetMessage("fail")) + "<br />"; txt += "* " + MessageResource.GetMessage("numbers") + ": " + (!check.DigitError ? MessageResource.GetMessage("ok") : MessageResource.GetMessage("fail")) + "<br />"; txt += "* " + MessageResource.GetMessage("symbols") + ": " + (!check.SymbolError ? MessageResource.GetMessage("ok") : MessageResource.GetMessage("fail")); ret = new WebJsonResponse("", MessageResource.GetMessage("password_complexity") + ": <br />" + txt, 5000, true); } } else { DataTable c = db.Select("select * from entity where deleted = 0 and id = " + login.Id); if ((c != null) && (c.Rows.Count > 0)) { //Verifica a senha atual using (EnterpriseKeyConfig sk = new EnterpriseKeyConfig(db.Connection, enterpriseId)) using (CryptApi cApi = CryptApi.ParsePackage(sk.ServerPKCS12Cert, Convert.FromBase64String(c.Rows[0]["password"].ToString()))) if (Encoding.UTF8.GetString(cApi.clearData) != currentPassword) { ret = new WebJsonResponse("", MessageResource.GetMessage("current_password_invalid"), 3000, true); } else { using (SqlConnection conn1 = IAMDatabase.GetWebConnection()) using (EnterpriseKeyConfig sk1 = new EnterpriseKeyConfig(conn1, enterpriseId)) using (CryptApi cApi1 = new CryptApi(sk.ServerCert, Encoding.UTF8.GetBytes(password))) { DbParameterCollection pPar = new DbParameterCollection();; String b64 = Convert.ToBase64String(cApi1.ToBytes()); pPar.Add("@password", typeof(String), b64.Length).Value = b64; db.ExecuteNonQuery("update entity set password = @password, change_password = getdate() , recovery_code = null, must_change_password = 0 where id = " + login.Id, CommandType.Text, pPar); } db.AddUserLog(LogKey.User_PasswordChanged, null, "AutoService", UserLogLevel.Info, 0, enterpriseId, 0, 0, 0, login.Id, 0, "Password changed through autoservice logged user", "{ \"ipaddr\":\"" + Tools.Tool.GetIPAddress() + "\"} "); //Cria o pacote com os dados atualizados deste usuário //Este processo visa agiliar a aplicação das informações pelos plugins db.ExecuteNonQuery("insert into deploy_now (entity_id) values(" + login.Id + ")", CommandType.Text, null); /* * IAMDeploy deploy = null; * * using (ServerDBConfig conf = new ServerDBConfig(IAMDatabase.GetWebConnection())) * deploy = new IAMDeploy("WebServer", DB.GetConnectionString(), conf.GetItem("outboundFiles")); * * if (deploy != null) * deploy.DeployOne(login.Id);*/ String html = ""; html += "<div class=\"no-tabs pb10\">"; html += " <div class=\"form-group\">"; html += " <h1>" + MessageResource.GetMessage("password_changed_sucessfully") + "</h1> "; html += " </div>"; html += " <div class=\"form-group\"><span class=\"text-message\">" + MessageResource.GetMessage("password_changed_text") + "</span></div>"; html += "</div>"; ret = new WebJsonResponse("#pwdForm", html); } } else { ret = new WebJsonResponse("", "Internal error", 3000, true); } } } finally { } } } } catch (Exception ex) { Tools.Tool.notifyException(ex); throw ex; } } if (ret != null) { ReturnHolder.Controls.Add(new LiteralControl(ret.ToJSON())); } }
protected void Page_Load(object sender, EventArgs e) { if (!EnterpriseIdentify.Identify(this)) //Se houver falha na identificação da empresa finaliza a resposta { return; } LoginData login = LoginUser.LogedUser(this); if (login != null) { Response.Redirect("/autoservice/"); } if ((Session["entity_id"] == null) || !(Session["entity_id"] is Int64)) { Response.Redirect("/login/"); } String html = ""; using (IAMDatabase db = new IAMDatabase(IAMDatabase.GetWebConnectionString())) { DataTable c = db.Select("select * from entity where deleted = 0 and id = " + Session["entity_id"]); if ((c != null) && (c.Rows.Count > 0)) { html = ""; html += "<div class=\"login_form\">"; html += "<ul>"; html += " <li>"; html += " <p style=\"width:100%;padding:0 0 5px 0;color:#000;\">" + MessageResource.GetMessage("password_expired_text") + "</p>"; html += " </li>"; html += " <li>"; html += " <span class=\"inputWrap\">"; //html += " <span id=\"ph_current_password\" class=\"noSel\" style=\"position: absolute; z-index: 1; top: 13px; left: 53px; color: rgb(204, 204, 204); display: block;\">" + MessageResource.GetMessage("current_password") + "</span>"; html += " <input type=\"password\" id=\"current_password\" tabindex=\"1\" name=\"current_password\" value=\"\" style=\"\" placeholder=\""+ MessageResource.GetMessage("current_password") + "\" onfocus=\"$('#current_password').addClass('focus');\" onblur=\"$('#current_password').removeClass('focus');\" />"; html += " <span id=\"ph_passwordIcon\" onclick=\"$('#password').focus();\"></span>"; html += " </span>"; html += " </li>"; html += " <li>"; html += " <span class=\"inputWrap\">"; //html += " <span id=\"ph_password\" class=\"noSel\" style=\"position: absolute; z-index: 1; top: 13px; left: 53px; color: rgb(204, 204, 204); display: block;\">" + MessageResource.GetMessage("new_password") + "</span>"; html += " <input type=\"password\" id=\"password\" tabindex=\"1\" name=\"password\" value=\"\" style=\"\" placeholder=\""+ MessageResource.GetMessage("new_password") + "\" onkeyup=\"iamadmin.passwordStrength('#password');\" onfocus=\"$('#password').addClass('focus');\" onblur=\"$('#password').removeClass('focus');\" />"; html += " <span id=\"ph_passwordIcon\" onclick=\"$('#password').focus();\"></span>"; html += " </span>"; html += " </li>"; html += " <li>"; html += " <span class=\"inputWrap\">"; //html += " <span id=\"ph_password2\" class=\"noSel\" style=\"position: absolute; z-index: 1; top: 13px; left: 53px; color: rgb(204, 204, 204); display: block;\">" + MessageResource.GetMessage("new_password_confirm") + "</span>"; html += " <input type=\"password\" id=\"password2\" tabindex=\"1\" name=\"password2\" value=\"\" style=\"\" placeholder=\""+ MessageResource.GetMessage("new_password_confirm") + "\" onfocus=\"$('#password2').addClass('focus');\" onblur=\"$('#password2').removeClass('focus');\" />"; html += " <span id=\"ph_passwordIcon\" onclick=\"$('#password2').focus();\"></span>"; html += " </span>"; html += " </li>"; html += " <li>"; html += " <div id=\"passwordStrength\"><span>" + MessageResource.GetMessage("password_strength") + ": " + MessageResource.GetMessage("unknow") + "</span><div class=\"bar\"></div></div>"; html += " </li>"; html += " <li>"; html += " <button tabindex=\"4\" id=\"submitBtn\" class=\"action button floatright\">" + MessageResource.GetMessage("change_password") + "</button>"; html += " </li>"; html += "</ul> "; html += "</div>"; } else { Tools.Tool.notifyException(new Exception("User not found in change password"), this); html = ""; html += "<div class=\"login_form\">"; html += "<ul>"; html += " <li>"; html += " <p style=\"width:100%;padding:0 0 5px 0;color:#000;\">" + MessageResource.GetMessage("user_not_found") + "</p>"; html += " </li>"; html += " <li>"; html += " <span class=\"forgot\"> <a href=\"/\">" + MessageResource.GetMessage("cancel") + "</a></span>"; html += " </li>"; html += "</ul> "; html += "</div>"; } } holderContent.Controls.Add(new LiteralControl(html)); }