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) { 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) { MAutoservice mClass = ((MAutoservice)this.Master); Tools.Tool.UpdateUri(this); LoginData login = LoginUser.LogedUser(this.Page); Boolean isAdmin = false; if (login != null) { IAMDatabase database = new IAMDatabase(IAMDatabase.GetWebConnectionString()); try { Int64 enterpriseId = 0; if ((Session["enterprise_data"]) != null && (Session["enterprise_data"] is EnterpriseData)) { enterpriseId = ((EnterpriseData)Session["enterprise_data"]).Id; } using (IAMRBAC rbac = new IAMRBAC()) isAdmin = rbac.HasAdminConsole(database, login.Id, enterpriseId); } catch { } } String html = ""; html += "<ul class=\"home\">"; if (isAdmin) { html += " <li><a href=\"" + Session["ApplicationVirtualPath"] + "admin/\"><div class=\"btn c2\"><div class=\"inner\"><i class=\"icon-change\"></i><span>Admin</span></div></div></a></li>"; } html += " <li><a href=\"" + Session["ApplicationVirtualPath"] + "autoservice/user/\"><div class=\"btn c3\"><div class=\"inner\"><i class=\"icon-profile\"></i><span>Informações gerais</span></div></div></a></li>"; html += " <li><a href=\"" + Session["ApplicationVirtualPath"] + "autoservice/user/changepassword/\"><div class=\"btn c1\"><div class=\"inner\"><i class=\"icon-key\"></i><span>Alterar senha</span></div></div></a></li>"; html += " <li><a href=\"" + Session["ApplicationVirtualPath"] + "autoservice/access_request/\"><div class=\"btn c5\"><div class=\"inner\"><i class=\"icon-page\"></i><span>Requisição de acesso</span></div></div></a></li>"; html += " <li><a href=\"" + Session["ApplicationVirtualPath"] + "logout/\"><div class=\"btn c4\"><div class=\"inner\"><i class=\"icon-exit\"></i><span>Desconectar</span></div></div></a></li>"; html += "</ul>"; contentHolder.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; } 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) { String html = ""; String error = ""; 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 { if (Request.HttpMethod == "POST") { try { Int64 userId = LoginUser.FindUser(this, Request["username"], out error); if (userId > 0) { Session["user_info"] = userId; Response.Redirect(Session["ApplicationVirtualPath"] + "login2/recover/step1/", false); return; } /*else if ((user.Emails == null) || (user.Emails.Count == 0)) * { * error = MessageResource.GetMessage("user_email_list"); * } * else * { * error = user.ErrorText; * }*/ } catch (Exception ex) { Tools.Tool.notifyException(ex); error = MessageResource.GetMessage("internal_error"); } } html += "<form id=\"serviceLogin\" name=\"serviceLogin\" method=\"post\" action=\"" + Session["ApplicationVirtualPath"] + "login2/recover/\"><div class=\"login_form\">"; 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 += " <input type=\"text\" id=\"username\" tabindex=\"1\" name=\"username\" value=\""+ Request["username"] + "\" style=\"\" placeholder=\"" + MessageResource.GetMessage("login_user_name") + "\" onfocus=\"$('#username').addClass('focus');\" onblur=\"$('#username').removeClass('focus');\" />"; html += " <span id=\"ph_userLoginIcon\" onclick=\"$('#username').focus();\"></span>"; html += " </span>"; html += " </li>"; if (error != "") { html += " <li><div class=\"error-box\">" + error + "</div>"; } html += " </li>"; html += " <li>"; html += " <span class=\"forgot\"> <a href=\"" + Session["ApplicationVirtualPath"] + "login2/\">" + MessageResource.GetMessage("cancel") + "</a> </span>"; html += " <button tabindex=\"4\" id=\"submitBtn\" class=\"action button floatright\">" + MessageResource.GetMessage("login_recover_btn_recover") + "</button>"; html += " </li>"; html += " </ul> "; html += "</div></form>"; holderContent.Controls.Add(new LiteralControl(html)); } }
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 contentRet = null; String action = ""; if (!String.IsNullOrWhiteSpace((String)RouteData.Values["action"])) { action = (String)RouteData.Values["action"]; } LoginData login = LoginUser.LogedUser(this.Page); Int64 requestId = 0; if (action != "add_request") { try { requestId = Int64.Parse((String)RouteData.Values["id"]); if (requestId < 0) { requestId = 0; } } catch { } if (requestId == 0) { contentRet = new WebJsonResponse("", MessageResource.GetMessage("workflow_request_not_found"), 3000, true); action = ""; } } String rData = ""; //SqlConnection //conn = DB.GetConnection(); String jData = ""; try { switch (action) { case "add_request": String workflow_id = Request.Form["workflow"]; if (String.IsNullOrEmpty(workflow_id)) { contentRet = new WebJsonResponse("", MessageResource.GetMessage("select_workflow"), 3000, true); break; } String description = Request.Form["description"]; if (String.IsNullOrEmpty(description)) { contentRet = new WebJsonResponse("", MessageResource.GetMessage("type_description"), 3000, true); break; } rData = JSON.Serialize2(new { jsonrpc = "1.0", method = "user.accessrequest", parameters = new { workflowid = workflow_id, userid = login.Id, description = description }, id = 1 }); using (IAMDatabase database = new IAMDatabase(IAMDatabase.GetWebConnectionString())) jData = WebPageAPI.ExecuteLocal(database, this, rData); if (String.IsNullOrWhiteSpace(jData)) { throw new Exception(""); } BooleanResult retAddR = JSON.Deserialize <BooleanResult>(jData); if (retAddR == null) { contentRet = new WebJsonResponse("", "Undefined erro on insert new request", 3000, true); } else if (retAddR.error != null) { contentRet = new WebJsonResponse("", retAddR.error.data, 3000, true); } else if (!retAddR.result) { contentRet = new WebJsonResponse("", "Undefined erro on insert new request", 3000, true); } else { contentRet = new WebJsonResponse(Session["ApplicationVirtualPath"] + "autoservice/access_request/"); } // break; } } catch (Exception ex) { contentRet = new WebJsonResponse("", MessageResource.GetMessage("api_error"), 3000, true); } finally { } if (contentRet != null) { if (!String.IsNullOrWhiteSpace((String)Request["cid"])) { contentRet.callId = (String)Request["cid"]; } Retorno.Controls.Add(new LiteralControl(contentRet.ToJSON())); } }
protected void Page_Load(object sender, EventArgs e) { MAutoservice mClass = ((MAutoservice)this.Master); menu1 = menu2 = menu3 = null; String ApplicationVirtualPath = Session["ApplicationVirtualPath"].ToString(); menu1 = new LMenu("Home", ApplicationVirtualPath + "autoservice/"); menu3 = new LMenu("Usuário", ApplicationVirtualPath + "autoservice/user/"); login = LoginUser.LogedUser(this.Page); if (login == null) { Session["last_page"] = Request.ServerVariables["PATH_INFO"]; Response.Redirect("/login/"); } String action = ""; if (RouteData.Values["action"] != null) { action = RouteData.Values["action"].ToString().ToLower(); } String html = ""; switch (action) { case "changepassword": subtitle = "Troca de senha"; html += "<section><form id=\"pwdForm\" name=\"pwdForm\" method=\"post\" action=\"/consoleapi/changepassword/\" onsubmit=\"return iamadmin.GenericSubmit('#pwdForm');\">"; html += " <div class=\"no-tabs pb10\">"; html += " <div class=\"form-group\">"; html += " <label>" + MessageResource.GetMessage("current_password") + "</label>"; html += " <input id=\"current_password\" name=\"current_password\" placeholder=\"" + MessageResource.GetMessage("current_password") + "\" type=\"password\" maxlength=\"128\" maxlength=\"128\" onfocus=\"$('#current_password').addClass('focus');\" onblur=\"$('#current_password').removeClass('focus');\">"; html += " </div>"; html += " <div class=\"form-group\">"; html += " <label>" + MessageResource.GetMessage("new_password") + "</label>"; html += " <input id=\"password\" name=\"password\" placeholder=\"" + MessageResource.GetMessage("new_password") + "\" type=\"password\" maxlength=\"128\" maxlength=\"128\" onkeyup=\"iamadmin.passwordStrength('#password');\" onfocus=\"$('#password').addClass('focus');\" onblur=\"$('#password').removeClass('focus');\">"; html += " </div>"; html += " <div class=\"form-group\">"; html += " <label>" + MessageResource.GetMessage("new_password_confirm") + "</label>"; html += " <input id=\"password2\" name=\"password2\" placeholder=\"" + MessageResource.GetMessage("new_password_confirm") + "\" type=\"password\" maxlength=\"128\" onfocus=\"$('#password2').addClass('focus');\" onblur=\"$('#password2').removeClass('focus');\">"; html += " </div>"; html += " <div id=\"passwordStrength\" class=\"form-group\">"; html += " <label>" + MessageResource.GetMessage("password_strength") + "</label>"; html += " <div class=\"form-group-content\"><span>" + MessageResource.GetMessage("unknow") + "</span><div class=\"bar\"></div></div>"; html += " </div>"; html += " <div class=\"clear-block\"></div>"; html += " </div>"; html += " <button type=\"submit\" id=\"user-profile-password-save\" class=\"button secondary floatleft\">" + MessageResource.GetMessage("change_password") + "</button>"; html += " <a href=\"" + ApplicationVirtualPath + "autoservice/user/\" class=\"button link floatleft\">" + MessageResource.GetMessage("cancel") + "</a>"; html += "</form></section>"; break; default: subtitle = "Informações gerais"; html += "<section><form>"; html += " <div class=\"no-tabs pb10\">"; html += " <div class=\"form-group\">"; html += " <label>Nome</label>"; html += " <span class=\"no-edit\">" + login.FullName + "</span>"; html += " </div>"; html += " <div class=\"form-group\">"; html += " <label>Login</label>"; html += " <span class=\"no-edit\">" + login.Login + "</span>"; html += " </div>"; html += " <div class=\"clear-block\"></div>"; html += " </div>"; html += "</form></section>"; break; } contentHolder.Controls.Add(new LiteralControl(html)); String sideHTML = ""; sideHTML += "<ul class=\"user-profile\">"; sideHTML += " <li id=\"user-profile-general\" " + (action == "" ? "class=\"bold\"" : "") + "><span><a href=\"" + ApplicationVirtualPath + "autoservice/user/\">Informações gerais</a></span></li>"; sideHTML += " <li id=\"user-profile-password\" " + (action == "changepassword" ? "class=\"bold\"" : "") + "><span><a href=\"" + ApplicationVirtualPath + "autoservice/user/changepassword/\">Troca de senha</a></span></li>"; //sideHTML += " <i id=\"scans-expand-filters\" class=\"icon-right\"></i>"; //sideHTML += " <li id=\"user-profile-tags\" " + (action == "" ? "class=\"bold\"" : "") + " href=\"#/users/edit/64764a0f77d1af87fbf808c3c043348c/folders\"><span>Folders</span></li>"; //sideHTML += " <li id=\"user-profile-plugin-rules\" " + (action == "" ? "class=\"bold\"" : "") + " href=\"#/users/edit/64764a0f77d1af87fbf808c3c043348c/rules\" class=\"mHide\"><span>Plugin Rules</span></li>"; sideHTML += "</ul>"; sideHolder.Controls.Add(new LiteralControl(sideHTML)); String titleBarHTML = ""; titleBarHTML += "<ul class=\"mobile-button-bar w50 \">"; titleBarHTML += " <li id=\"user-profile-general-mobile\" " + (action == "" ? "class=\"on\"" : "") + "><a href=\"" + ApplicationVirtualPath + "autoservice/user/\">Informações gerais</a></li>"; titleBarHTML += " <li id=\"user-profile-password-mobile\" " + (action == "changepassword" ? "class=\"on\"" : "") + "><a href=\"" + ApplicationVirtualPath + "autoservice/user/changepassword/\">Troca de senha</a></li>"; titleBarHTML += "</ul>"; titleBarContent.Controls.Add(new LiteralControl(titleBarHTML)); }
protected void Page_Load(object sender, EventArgs e) { String html = ""; String error = ""; 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 { if (Request.HttpMethod == "POST") { try { AuthBase authPlugin = null; try { //Força sempre usar o plugin 'internal' //Para haver uma autenticação alternativa ao CAS authPlugin = AuthBase.GetPlugin(new Uri("auth://iam/plugins/internal")); } catch { } if (authPlugin == null) { throw new Exception("Plugin não encontrado"); } LoginResult ret = null; using (IAMDatabase db = new IAMDatabase(IAMDatabase.GetWebConnectionString())) ret = authPlugin.Auth(db, this); if (!ret.Success) { error = ret.Text; } } catch (Exception ex) { //Tools.Tool.notifyException(ex, this); error = "Erro: " + ex.Message; } } html += "<form id=\"serviceLogin\" name=\"serviceLogin\" method=\"post\" action=\"" + Session["ApplicationVirtualPath"] + "login2/\"><div class=\"login_form\">"; html += " <ul>"; html += " <li>"; html += " <span class=\"inputWrap\">"; html += " <input type=\"text\" id=\"username\" tabindex=\"1\" name=\"username\" value=\""+ Request["username"] + "\" style=\"\" placeholder=\"" + MessageResource.GetMessage("login_user_name") + "\" onfocus=\"$('#username').addClass('focus');\" onblur=\"$('#username').removeClass('focus');\" />"; html += " <span id=\"ph_userLoginIcon\" onclick=\"$('#username').focus();\"></span>"; html += " </span>"; html += " </li>"; html += " <li>"; html += " <span class=\"inputWrap\">"; 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>"; if (error != "") { html += " <li><div class=\"error-box\">" + error + "</div>"; } html += " </li>"; html += " <li>"; html += " <span class=\"forgot\"> <a href=\"" + Session["ApplicationVirtualPath"] + "login2/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></form>"; holderContent.Controls.Add(new LiteralControl(html)); } }
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)); }
protected void Page_Load(object sender, EventArgs e) { String html = ""; String error = ""; html += "<form id=\"serviceLogin\" name=\"serviceLogin\" method=\"post\" action=\"" + Session["ApplicationVirtualPath"] + "login2/recover/step2/\"><div class=\"login_form\">"; 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/", false); } } else if (Session["user_info"] == null || !(Session["user_info"] is Int64)) { //Serviço não informado ou não encontrado html += " <ul>"; html += " <li><div class=\"error-box\">" + MessageResource.GetMessage("invalid_session") + "</div>"; html += " </ul>"; } else { Int64 entityId = (Int64)Session["user_info"]; String err = ""; if (Request.HttpMethod == "POST") { String userCode = Request["userCode"]; if ((userCode == null) || (userCode == "")) { error = MessageResource.GetMessage("type_code"); } else { if (entityId > 0) { using (IAMDatabase db = new IAMDatabase(IAMDatabase.GetWebConnectionString())) { DataTable c = db.Select("select * from entity where deleted = 0 and id = " + entityId + " and recovery_code = '" + Tools.Tool.TrataInjection(userCode) + "'"); if ((c != null) && (c.Rows.Count > 0)) { Session["userCode"] = c.Rows[0]["recovery_code"].ToString(); Response.Redirect(Session["ApplicationVirtualPath"] + "login2/recover/step3/", false); return; } else { error = MessageResource.GetMessage("invalid_code"); } } } else { error = MessageResource.GetMessage("invalid_session"); } } } html += "<ul>"; html += " <li>"; html += " <p style=\"width:100%;padding:0 0 5px 0;color:#000;\">" + MessageResource.GetMessage("enter_code") + "</p>"; html += " </li>"; html += " <li>"; html += " <span class=\"inputWrap\">"; html += " <input type=\"text\" id=\"userCode\" tabindex=\"1\" name=\"userCode\" value=\"\" style=\"\" placeholder=\""+ MessageResource.GetMessage("code") + "\" onfocus=\"$('#userCode').addClass('focus');\" onblur=\"$('#userCode').removeClass('focus');\" />"; html += " <span id=\"ph_passwordIcon\" onclick=\"$('#userCode').focus();\"></span>"; html += " </span>"; html += " </li>"; if (error != "") { html += " <ul>"; html += " <li><div class=\"error-box\">" + error + "</div>"; html += " </ul>"; } 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("confirm_code") + "</button>"; html += " </li>"; html += "</ul> "; } html += "</div></form>"; holderContent.Controls.Add(new LiteralControl(html)); }
protected void Page_Load(object sender, EventArgs e) { MAutoservice mClass = ((MAutoservice)this.Master); menu1 = menu2 = menu3 = null; String ApplicationVirtualPath = Session["ApplicationVirtualPath"].ToString(); menu1 = new LMenu("Home", ApplicationVirtualPath + "autoservice/"); menu3 = new LMenu("Requisição de acesso", ApplicationVirtualPath + "autoservice/access_request/"); login = LoginUser.LogedUser(this.Page); if (login == null) { Session["last_page"] = Request.ServerVariables["PATH_INFO"]; Response.Redirect("/login/"); } String action = ""; if (RouteData.Values["action"] != null) { action = RouteData.Values["action"].ToString().ToLower(); } String errorTemplate = "<span class=\"empty-results\">{0}</span>"; String infoTemplate = "<tr><td class=\"col1\">{0}</td><td class=\"col2\"><span class=\"no-edit\">{1}</span></td></tr>"; String html = ""; String eHtml = ""; String js = ""; String rData = ""; String jData = ""; String sideHTML = ""; if (action != "new") { sideHTML += "<div class=\"sep\"><button class=\"a-btn-big a-btn\" type=\"button\" onclick=\"window.location='" + ApplicationVirtualPath + "autoservice/access_request/new/'\">Nova requisição</button></div>"; } //Verifica se está selecionado o usuário switch (action) { case "new": subtitle = "Nova requisição de acesso"; using (IAMDatabase database = new IAMDatabase(IAMDatabase.GetWebConnectionString())) { //Busca todos os workflows disponíveis no mesmo contexto do usuário atual que esteja habilitado DataTable dtWorkflow = database.ExecuteDataTable("select w.* from st_workflow w with(nolock) inner join context c with(nolock) on c.id = w.context_id inner join entity e with(nolock) on e.context_id = c.id where w.enabled = 1 and w.deprecated = 0 and e.id = " + login.Id + " order by w.name"); if ((dtWorkflow == null) || (dtWorkflow.Rows.Count == 0)) { eHtml += String.Format(errorTemplate, "Nenhuma acesso disponível para solicitação"); } else { js += "<script type=\"text/javascript\">"; js += "$( document ).ready(function() {"; js += " $('#workflow').change(function() {"; js += " $('#desc_text').html('');"; js += " $('#desc_text').html( $('option:selected', this ).attr('description') );"; js += " });"; js += "});"; js += "</script>"; html += "<form id=\"form_add_role\" method=\"post\" action=\"" + ApplicationVirtualPath + "autoservice/access_request/action/add_request/\">"; html += "<div class=\"no-tabs fields\"><table><tbody>"; String select = "<select id=\"workflow\" name=\"workflow\" ><option value=\"\"></option>"; foreach (DataRow dr in dtWorkflow.Rows) { select += "<option value=\"" + dr["id"] + "\" description=\"" + HttpUtility.HtmlEncode(dr["description"]) + "\">" + dr["name"] + "</option>"; } select += "</select><span id=\"desc_text\" class=\"description\" style=\"padding: 5px 0 0 0;\"></span>"; html += String.Format(infoTemplate, "Acesso", select); html += String.Format(infoTemplate, "Descrição da necessidade do acesso", "<textarea id=\"description\" name=\"description\" rows=\"5\" placeholder=\"Digite a justificativa para necessidade de acesso\"></textarea>"); html += "</tbody></table><div class=\"clear-block\"></div></div>"; html += "<button type=\"submit\" id=\"user-profile-password-save\" class=\"button secondary floatleft\">Salvar</button> <a href=\"" + ApplicationVirtualPath + "autoservice/access_request/\" class=\"button link floatleft\">Cancelar</a></form>"; } } break; default: Int64 id = 0; try { id = Int64.Parse((String)RouteData.Values["id"]); if (id < 0) { id = 0; } } catch { } if (id > 0) { using (IAMDatabase database = new IAMDatabase(IAMDatabase.GetWebConnectionString())) { subtitle = "Requisição de acesso"; DataTable drRequest = database.ExecuteDataTable("select * from st_workflow_request r with(nolock) where r.id = " + id); if ((drRequest != null) && (drRequest.Rows.Count > 0)) { WorkflowConfig workflow = new WorkflowConfig(); workflow.GetDatabaseData(database, (Int64)drRequest.Rows[0]["workflow_id"]); WorkflowRequestStatus status = (WorkflowRequestStatus)((Int32)drRequest.Rows[0]["status"]); DataTable drRequestStatus = database.ExecuteDataTable("select r.*, a.name activity_name from st_workflow_request_status r with(nolock) inner join st_workflow_activity a with(nolock) on r.activity_id = a.id where r.workflow_request_id = " + drRequest.Rows[0]["id"] + " order by date desc"); DataTable drActivity = database.ExecuteDataTable("select * from st_workflow_activity a with(nolock) where a.workflow_id = " + workflow.WorkflowId + " order by a.execution_order"); //html += "<form id=\"form_add_role\" method=\"post\" action=\"" + ApplicationVirtualPath + "autoservice/access_request/action/add_request/\">"; html += "<div class=\"no-tabs fields\"><table><tbody>"; html += String.Format(infoTemplate, "Acesso", "<span class=\"no-edit\">" + workflow.Name + "<span class=\"description\">" + workflow.Description + "</span></span>"); html += String.Format(infoTemplate, "Último status", MessageResource.GetMessage("wf_" + status.ToString().ToLower())); html += String.Format(infoTemplate, "Data da requisição", MessageResource.FormatDate((DateTime)drRequest.Rows[0]["create_date"], false)); html += String.Format(infoTemplate, "Descrição da necessidade do acesso", drRequest.Rows[0]["description"].ToString()); //html += String.Format(infoTemplate, "", "<span type=\"submit\" id=\"cancel\" class=\"button secondary floatleft red\">Cancelar requisição</span>"); //sideHTML += "<div class=\"sep\"><button class=\"a-btn-big a-btn\" type=\"button\" onclick=\"window.location='" + ApplicationVirtualPath + "autoservice/access_request/new/'\">Nova requisição</button></div>"; html += "</tbody></table><div class=\"clear-block\"></div></div>"; html += "<h3>Passos de aprovação</h3>"; html += "<div class=\"sep\"><table id=\"users-table\" class=\"sorter\"><thead>"; html += " <tr>"; html += " <th class=\"pointer w80 header headerSortDown\" data-column=\"name\">Passo <div class=\"icomoon\"></div></th>"; html += " <th class=\"pointer header headerSortDown\" data-column=\"name\">Atividade <div class=\"icomoon\"></div></th>"; html += " <th class=\"pointer tHide mHide header\" data-column=\"status\">Último status <div class=\"icomoon\"></div></th>"; html += " </tr>"; html += "</thead>"; html += "<tbody>"; String trTemplate = " <tr class=\"request\" data-userid=\"{0}\">"; trTemplate += " <td class=\"ident10\">{1}</td>"; trTemplate += " <td class=\"tHide mHide\">{2}</td>"; trTemplate += " <td class=\"tHide mHide\">{3}</td>"; trTemplate += " </tr>"; Int32 step = 1; if ((drActivity != null) && (drActivity.Rows.Count > 0)) { foreach (DataRow dr in drActivity.Rows) { String st = ""; DateTime last = new DateTime(1970, 1, 1); if ((drRequestStatus != null) && (drRequestStatus.Rows.Count > 0)) { foreach (DataRow drSt in drRequestStatus.Rows) { if (drSt["activity_id"].ToString() == dr["id"].ToString()) { if (last.CompareTo((DateTime)drSt["date"]) < 0) { last = (DateTime)drSt["date"]; st = MessageResource.GetMessage("wf_" + ((WorkflowRequestStatus)((Int32)drSt["status"])).ToString().ToLower()); } } } } if (st == "") { st = "Aguardando aprovação da atividade anterior"; } html += String.Format(trTemplate, dr["id"], step++, dr["name"], st); } } html += "</tbody></table><div class=\"clear-block\"></div></div>"; html += "<h3>Todos os status</h3>"; html += "<table id=\"users-table\" class=\"sorter\"><thead>"; html += " <tr>"; html += " <th class=\"w50 mHide {sorter: false}\"><div class=\"select-all\"></div></th>"; html += " <th class=\"pointer w150 header headerSortDown\" data-column=\"name\">Data <div class=\"icomoon\"></div></th>"; html += " <th class=\"pointer w200 tHide mHide header\" data-column=\"status\">Status <div class=\"icomoon\"></div></th>"; html += " <th class=\"pointer tHide mHide header {sorter: false}\" data-column=\"create_date\">Atividade <div class=\"icomoon\"></div></th>"; html += " <th class=\"pointer tHide mHide header {sorter: false}\" data-column=\"create_date\">Descrição <div class=\"icomoon\"></div></th>"; html += " </tr>"; html += "</thead>"; html += "<tbody>"; trTemplate = " <tr class=\"request\" data-userid=\"{0}\">"; trTemplate += " <td class=\"select mHide\"><div class=\"checkbox\"></div></td>"; trTemplate += " <td class=\"\">{1}</td>"; trTemplate += " <td class=\"tHide mHide\">{2}</td>"; trTemplate += " <td class=\"tHide mHide\">{3}</td>"; trTemplate += " <td class=\"tHide mHide\">{4}</td>"; trTemplate += " </tr>"; if ((drRequestStatus != null) && (drRequestStatus.Rows.Count > 0)) { foreach (DataRow dr in drRequestStatus.Rows) { try { html += String.Format(trTemplate, dr["id"], MessageResource.FormatDate((DateTime)dr["date"], false), MessageResource.GetMessage("wf_" + ((WorkflowRequestStatus)((Int32)dr["status"])).ToString().ToLower()), dr["activity_name"], dr["description"]); } catch (Exception ex) { } } } html += "</tbody></table>"; //html += "<button type=\"submit\" id=\"user-profile-password-save\" class=\"button secondary floatleft\">Salvar</button> <a href=\"" + ApplicationVirtualPath + "autoservice/access_request/\" class=\"button link floatleft\">Cancelar</a></form>"; } else { eHtml += String.Format(errorTemplate, "Requisição não encontrada"); } } } else //Request não selecionado { subtitle = "Requisição de acesso"; js += "<script type=\"text/javascript\">"; js += "$( document ).ready(function() {"; js += " $('table tbody tr').each(function (index, element) {"; js += " if ($(this).attr('data-href')) {"; js += " $(this).unbind('click');"; js += " $(this).click(function (event) {"; js += " event.preventDefault();"; js += " window.location = $(this).attr('data-href');"; js += " });"; js += " }"; js += " });"; js += "});"; js += "</script>"; using (IAMDatabase database = new IAMDatabase(IAMDatabase.GetWebConnectionString())) { DataTable dtWorkflowRequests = database.ExecuteDataTable("select * from st_workflow_request where entity_id = " + login.Id + " order by create_date desc"); if ((dtWorkflowRequests == null) || (dtWorkflowRequests.Rows.Count == 0)) { eHtml += String.Format(errorTemplate, "Nenhuma requisição cadastrada"); } else { html += "<table id=\"users-table\" class=\"sorter\"><thead>"; html += " <tr>"; html += " <th class=\"w50 mHide {sorter: false}\"><div class=\"select-all\"></div></th>"; html += " <th class=\"pointer header headerSortDown\" data-column=\"name\">Nome <div class=\"icomoon\"></div></th>"; html += " <th class=\"pointer tHide mHide header\" data-column=\"status\">Status <div class=\"icomoon\"></div></th>"; html += " <th class=\"pointer w150 tHide mHide header\" data-column=\"create_date\">Data de criação <div class=\"icomoon\"></div></th>"; html += " </tr>"; html += "</thead>"; html += "<tbody>"; String trTemplate = " <tr class=\"request\" data-userid=\"{0}\" data-href=\"" + ApplicationVirtualPath + "autoservice/access_request/{0}/\">"; trTemplate += " <td class=\"select mHide\"><div class=\"checkbox\"></div></td>"; trTemplate += " <td class=\"pointer ident10\">{1}</td>"; trTemplate += " <td class=\"pointer tHide mHide\">{2}</td>"; trTemplate += " <td class=\"pointer tHide mHide\">{3}</td>"; trTemplate += " </tr>"; foreach (DataRow dr in dtWorkflowRequests.Rows) { try { WorkflowConfig workflow = new WorkflowConfig(); workflow.GetDatabaseData(database, (Int64)dr["workflow_id"]); WorkflowRequestStatus status = (WorkflowRequestStatus)((Int32)dr["status"]); html += String.Format(trTemplate, dr["id"].ToString(), workflow.Name, MessageResource.GetMessage("wf_" + status.ToString().ToLower()), ((DateTime)dr["create_date"]).ToString("yyyy-MM-dd HH:mm:ss")); } catch (Exception ex) { } } html += "</tbody></table>"; } } } break; } headContent.Controls.Add(new LiteralControl(js)); contentHolder.Controls.Add(new LiteralControl((eHtml != "" ? eHtml : html))); sideHTML += "<ul class=\"user-profile\">"; sideHTML += " <li id=\"user-profile-general\" " + (action == "" ? "class=\"bold\"" : "") + "><span><a href=\"" + ApplicationVirtualPath + "autoservice/access_request/\">Requisições realizadas</a></span></li>"; //sideHTML += " <li id=\"user-profile-password\" " + (action == "changepassword" ? "class=\"bold\"" : "") + "><span><a href=\"" + ApplicationVirtualPath + "autoservice/access_request/new/\">Nova requisição</a></span></li>"; sideHTML += "</ul>"; sideHolder.Controls.Add(new LiteralControl(sideHTML)); String titleBarHTML = ""; /* * titleBarHTML += "<ul class=\"mobile-button-bar w50 \">"; * titleBarHTML += " <li id=\"user-profile-general-mobile\" "+ (action == "" ? "class=\"on\"" : "") + "><a href=\"" + ApplicationVirtualPath + "autoservice/user/\">Informações gerais</a></li>"; * titleBarHTML += " <li id=\"user-profile-password-mobile\" " + (action == "changepassword" ? "class=\"on\"" : "") + "><a href=\"" + ApplicationVirtualPath + "autoservice/user/changepassword/\">Troca de senha</a></li>"; * titleBarHTML += "</ul>";*/ titleBarContent.Controls.Add(new LiteralControl(titleBarHTML)); }
protected void Page_Load(object sender, EventArgs e) { String html = ""; String error = ""; html += "<form id=\"serviceLogin\" name=\"serviceLogin\" method=\"post\" action=\"" + Session["ApplicationVirtualPath"] + "login2/recover/step1/\"><div class=\"login_form\">"; 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/", false); } } else if (Session["user_info"] == null || !(Session["user_info"] is Int64)) { //Serviço não informado ou não encontrado html += " <ul>"; html += " <li><div class=\"error-box\">" + MessageResource.GetMessage("invalid_session") + "</div>"; html += " </ul>"; } else { Int64 entityId = (Int64)Session["user_info"]; Int64 enterpriseID = ((EnterpriseData)Page.Session["enterprise_data"]).Id; String err = ""; if (Request.HttpMethod == "POST") { String sentTo = Request["sentTo"]; if ((sentTo == null) || (sentTo == "")) { error = MessageResource.GetMessage("select_option"); } else { using (IAMDatabase db = new IAMDatabase(IAMDatabase.GetWebConnectionString())) { List <String> possibleData = new List <string>(); DataTable c = db.Select("select value from vw_entity_all_data where id = " + entityId); if ((c != null) && (c.Rows.Count > 0)) { foreach (DataRow dr in c.Rows) { if (!possibleData.Contains(dr["value"].ToString().ToLower())) { possibleData.Add(dr["value"].ToString().ToLower()); } } if (possibleData.Count > 0) { DirectoryInfo pluginPath = new DirectoryInfo(Path.Combine(HostingEnvironment.MapPath("~"), "code_plugins")); if (!pluginPath.Exists) { pluginPath.Create(); } List <CodeManagerPluginBase> plugins = CodePlugins.GetPlugins <CodeManagerPluginBase>(pluginPath.FullName); if (plugins.Count > 0) { CodeManagerPluginBase p = CodeManagerPluginBase.GetPluginByData(plugins, possibleData, sentTo); if (p != null) { try { DataTable tmp = db.Select(String.Format("select id, recovery_code from entity with(nolock) where deleted = 0 and id = {0}", entityId)); if ((tmp == null) || (tmp.Rows.Count == 0)) { error = MessageResource.GetMessage("entity_not_found"); } Dictionary <String, Object> config = new Dictionary <String, Object>(); using (DataTable c1 = db.Select("select [key], [value] from code_plugin_par where enterprise_id = " + enterpriseID + " and uri = '" + p.GetPluginId().AbsoluteUri + "'")) { if (c1 != null) { foreach (DataRow dr1 in c1.Rows) { CodeManagerPluginBase.FillConfig(p, ref config, dr1["key"].ToString(), dr1["value"]); } } if (p.SendCode(config, possibleData, sentTo, tmp.Rows[0]["recovery_code"].ToString())) { Response.Redirect(Session["ApplicationVirtualPath"] + "login2/recover/step2/", false); return; } else { error = "Erro enviando código de recuperação"; } } config.Clear(); config = null; } catch (Exception ex) { error = ex.Message; } } else { error = MessageResource.GetMessage("option_not_found"); } } else { error = MessageResource.GetMessage("option_not_found"); } } else { error = MessageResource.GetMessage("option_not_found"); } } else { error = MessageResource.GetMessage("option_not_found"); } //Resgata todos os plugind possíveis /* * DataTable c = db.Select("select * from vw_entity_mails where mail like '%@%' and entity_id = " + entityId); * if ((c != null) && (c.Rows.Count > 0)) * { * DataRow drSentTo = null; * foreach (DataRow dr in c.Rows) * { * String data = LoginUser.MaskData(dr["mail"].ToString(), true, false); * if (sentTo.ToString().ToLower() == data) * { * drSentTo = dr; * break; * } * } * * if (drSentTo == null) * error = MessageResource.GetMessage("option_not_found"); * else * { * * //if (LoginUser.SendCode(entityId, drSentTo["value"].ToString(), (Boolean)drSentTo["is_mail"], (Boolean)drSentTo["is_sms"], out err)) * if (LoginUser.SendCode(entityId, drSentTo["mail"].ToString(), true, false, out err)) * { * Response.Redirect(Session["ApplicationVirtualPath"] + "login2/recover/step2/", false); * return; * } * else * { * error = err; * } * * } * } * else * { * error = MessageResource.GetMessage("option_not_found"); * }*/ } } } LoginUser.NewCode(this, entityId, out err); if (err == "") { using (IAMDatabase db = new IAMDatabase(IAMDatabase.GetWebConnectionString())) { List <CodeData> dataList = new List <CodeData>(); List <String> possibleData = new List <string>(); DataTable c = db.Select("select value from vw_entity_all_data where id = " + entityId); if ((c != null) && (c.Rows.Count > 0)) { foreach (DataRow dr in c.Rows) { if (!possibleData.Contains(dr["value"].ToString().ToLower())) { possibleData.Add(dr["value"].ToString().ToLower()); } } if (possibleData.Count > 0) { DirectoryInfo pluginPath = new DirectoryInfo(Path.Combine(HostingEnvironment.MapPath("~"), "code_plugins")); if (!pluginPath.Exists) { pluginPath.Create(); } List <CodeManagerPluginBase> plugins = CodePlugins.GetPlugins <CodeManagerPluginBase>(pluginPath.FullName); if (plugins.Count > 0) { foreach (CodeManagerPluginBase p in plugins) { try { Dictionary <String, Object> config = new Dictionary <String, Object>(); using (DataTable c1 = db.Select("select [key], [value] from code_plugin_par where enterprise_id = " + enterpriseID + " and uri = '" + p.GetPluginId().AbsoluteUri + "'")) { if (c1 != null) { foreach (DataRow dr1 in c1.Rows) { CodeManagerPluginBase.FillConfig(p, ref config, dr1["key"].ToString(), dr1["value"]); } } //Verifica se existe as configs deste plugin e se estão válidas if (p.ValidateConfigFields(config)) { dataList.AddRange(p.ParseData(possibleData)); } } config.Clear(); config = null; } catch (Exception ex) { } } } } } if (dataList.Count > 0) { html += "<ul>"; html += " <li>"; html += " <p style=\"width:100%;padding:0 0 5px 0;color:#000;\">" + MessageResource.GetMessage("send_conf_to") + "</p>"; html += " </li>"; foreach (CodeData data in dataList) { html += " <li><p style=\"width:400px;padding:0 0 5px 10px;color:#000;\"><input name=\"sentTo\" type=\"radio\" value=\"" + data.DataId + "\">" + data.MaskedData + "</p></li>"; } if (error != "") { html += " <ul>"; html += " <li><div class=\"error-box\">" + error + "</div>"; html += " </ul>"; } 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("send_code") + "</button>"; html += " </li>"; html += "</ul> "; } else { html += "<ul>"; html += " <li>"; html += " <p style=\"width:100%;padding:0 0 5px 0;color:#000;\">No method available</p>"; html += " </li>"; html += " <li>"; html += " <span class=\"forgot\"> <a href=\"/\">" + MessageResource.GetMessage("cancel") + "</a></span>"; html += " </li>"; html += "</ul> "; } /* * //DataTable c = db.Select("select * from vw_entity_confirmations where enterprise_id = " + enterpriseID + " and entity_id = " + entityId); * DataTable c = db.Select("select * from vw_entity_mails where mail like '%@%' and entity_id = " + entityId); * if ((c != null) && (c.Rows.Count > 0)) * { * * html += "<ul>"; * html += " <li>"; * html += " <p style=\"width:100%;padding:0 0 5px 0;color:#000;\">" + MessageResource.GetMessage("send_conf_to") + "</p>"; * html += " </li>"; * * foreach (DataRow dr in c.Rows) * { * //String data = LoginUser.MaskData(dr["value"].ToString(), (Boolean)dr["is_mail"], (Boolean)dr["is_sms"]); * String data = LoginUser.MaskData(dr["mail"].ToString(), true, false); * if (data != "") * html += " <li><p style=\"width:400px;padding:0 0 5px 10px;color:#000;\"><input name=\"sentTo\" type=\"radio\" value=\"" + data + "\">" + data + "</p></li>"; * } * * if (error != "") * { * html += " <ul>"; * html += " <li><div class=\"error-box\">" + error + "</div>"; * html += " </ul>"; * } * * 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("send_code") + "</button>"; * html += " </li>"; * html += "</ul> "; * } * else * { * * html += "<ul>"; * html += " <li>"; * html += " <p style=\"width:100%;padding:0 0 5px 0;color:#000;\">No method available</p>"; * html += " </li>"; * html += " <li>"; * html += " <span class=\"forgot\"> <a href=\"/\">" + MessageResource.GetMessage("cancel") + "</a></span>"; * html += " </li>"; * html += "</ul> "; * }*/ } } else { html += " <ul>"; html += " <li><div class=\"error-box\">" + err + "</div>"; html += " </ul>"; } } html += "</div></form>"; holderContent.Controls.Add(new LiteralControl(html)); }
protected void Page_Load(object sender, EventArgs e) { String html = ""; String error = ""; LoginData login = LoginUser.LogedUser(this); if (login == null) { Response.Redirect(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath + "login2/", false); } else { html += "<form id=\"serviceLogin\" name=\"serviceLogin\" method=\"post\" action=\"" + Session["ApplicationVirtualPath"] + "login2/changepassword/\"><div class=\"login_form\">"; if (Request.HttpMethod == "POST") { try { String password = Tools.Tool.TrataInjection(Request["password"]); String password2 = Request["password2"]; if ((password == null) || (password == "")) { error = MessageResource.GetMessage("type_password"); } else if ((password2 == null) || (password2 == "")) { error = MessageResource.GetMessage("type_password_confirm"); } else if (password != password2) { error = MessageResource.GetMessage("password_not_equal"); } else { 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; } using (IAMDatabase db = new IAMDatabase(IAMDatabase.GetWebConnectionString())) { UserPasswordStrength usrCheck = new UserPasswordStrength(db.Connection, login.Id); UserPasswordStrengthResult check = usrCheck.CheckPassword(password); if (check.HasError) { if (check.NameError) { error = MessageResource.GetMessage("password_name_part"); } 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")); error = MessageResource.GetMessage("password_complexity") + ": <br />" + txt; } } 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()))) { 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 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); //Mata a sessão //Session.Abandon(); Response.Redirect(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath + "login2/passwordchanged/", false); } } else { error = MessageResource.GetMessage("internal_error"); } } } } } catch (Exception ex) { Tools.Tool.notifyException(ex); error = MessageResource.GetMessage("internal_error") + ": " + ex.Message; } } html += " <ul>"; html += " <li>"; html += " <p style=\"width:270px;padding:0 0 20px 0;color:#000;\">" + MessageResource.GetMessage("password_expired_text") + "</p>"; html += " </li>"; html += " <li>"; html += " <span class=\"inputWrap\">"; html += " <input type=\"password\" id=\"password\" tabindex=\"1\" name=\"password\" value=\"\" style=\"\" placeholder=\""+ MessageResource.GetMessage("new_password") + "\" onkeyup=\"cas.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 += " <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>"; if (error != "") { html += " <li><div class=\"error-box\">" + error + "</div>"; } html += " <li>"; html += " <span class=\"forgot\"> <a href=\"" + Session["ApplicationVirtualPath"] + "logout/\">" + MessageResource.GetMessage("cancel") + "</a> </span>"; html += " <button tabindex=\"4\" id=\"submitBtn\" class=\"action button floatright\">" + MessageResource.GetMessage("change_password") + "</button>"; html += " </li>"; html += " </ul>"; html += "</div></form>"; holderContent.Controls.Add(new LiteralControl(html)); } }
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())); } }