protected void Button1_Click(object sender, EventArgs e) { if (PageValidate()) { objBE.Action = "R"; objBE.User = user; DataTable dtLogin = new DataTable(); dtLogin = objLogin.getLoginDetails(objBE, ConnKey); if (dtLogin.Rows.Count > 0) { string password = dtLogin.Rows[0]["Password"].ToString(); string myval = ShaEncrypt(ViewState["KeyGenerator"].ToString()); string value = ShaEncrypt(password.ToLower() + myval.ToLower()); if (password.ToLower() != txtNewPwdHash.Value) { if (txtOldPwdHash.Value == value.ToLower()) { dt = objLogin.UpdatePWD(user, txtNewPwdHash.Value.ToString(), Request.ServerVariables["REMOTE_ADDR"].ToString(), ConnKey); if (dt.Rows.Count > 0) { objCommon.ShowAlertMessage("Password successfully changed"); Response.Redirect("login.aspx"); } else { txtOldPwdHash.Value = ""; txtNewPwdHash.Value = ""; objCommon.ShowAlertMessage("Invalid Old Password"); } } else { txtOldPwdHash.Value = ""; txtNewPwdHash.Value = ""; objCommon.ShowAlertMessage("Invalid Old Password"); } } else { objCommon.ShowAlertMessage("New Password should not be same as old password"); } } else { objCommon.ShowAlertMessage("New Password should not be same as old password"); } } }
protected void btnLogin_Click(object sender, EventArgs e) { check(); try { if (CheckCaptcha()) { objBE.Action = "R"; objBE.User = txtUname.Text; DataTable dtLogin = objLogin.getLoginDetails(objBE, ConnKey); if (dtLogin.Rows.Count > 0) { string password = dtLogin.Rows[0]["Password"].ToString(); string StateCode = dtLogin.Rows[0]["StateCode"].ToString(); string Statename = dtLogin.Rows[0]["State"].ToString(); string DistCode = dtLogin.Rows[0]["DistCode"].ToString(); string MandCode = dtLogin.Rows[0]["MandCode"].ToString(); string Department = dtLogin.Rows[0]["Department"].ToString(); string district = dtLogin.Rows[0]["DistName"].ToString(); string mandal = dtLogin.Rows[0]["MandName"].ToString(); string roleNm = dtLogin.Rows[0]["RoleName"].ToString(); string role = dtLogin.Rows[0]["role"].ToString(); string Code = dtLogin.Rows[0]["code"].ToString(); string Name = dtLogin.Rows[0]["Name"].ToString(); string ZoneName = dtLogin.Rows[0]["ZoneName"].ToString(); string ZoneCode = dtLogin.Rows[0]["ZoneCode"].ToString(); string LabName = dtLogin.Rows[0]["LabName"].ToString(); string LabCode = dtLogin.Rows[0]["Lab_Code"].ToString(); Session["UserId"] = dtLogin.Rows[0]["Sno"].ToString(); string myval = ShaEncrypt(ViewState["KeyGenerator"].ToString()); string value = ShaEncrypt(password.ToLower() + myval.ToLower()); if (txtPwdHash.Value == value.ToLower()) { string guid = Guid.NewGuid().ToString(); Session["AuthToken"] = guid; Response.ClearContent(); Response.Cookies.Add(new HttpCookie("AuthToken", guid)); Session["ConnKey"] = ConnKey; Session["Role"] = roleNm; Session["RoleID"] = role; Session["UsrName"] = txtUname.Text; Session["StateCode"] = StateCode; Session["Statename"] = Statename; Session["Department"] = Department; captch.Text = ""; Session["LoginSno"] = objLogin.insertUserLoginStatus(txtUname.Text, DateTime.Now, Request.ServerVariables["REMOTE_ADDR"].ToString(), "Login Successful", ConnKey); //if (password.ToUpper() == "6B4C8CBCB6B66F050C12D6A0203C58A8BC6D36E5A8C28B74111681F7AECE378A") //{ // Session["Role"] = roleNm; // Session["UsrName"] = txtUname.Text; // Session["StateCode"] = StateCode; // Session["distCode"] = DistCode; // Session["mandcode"] = MandCode; // Session["district"] = district; // Session["mandal"] = mandal; // Response.Redirect("ChangePWD.aspx", false); //} //else if (dtLogin.Rows[0]["Role"].ToString() == "0") { Response.Redirect("~/DCA/Admin/DashBoard.aspx", false); } else if (dtLogin.Rows[0]["Role"].ToString() == "1") { Session["DI_AO_Code"] = Code; Session["DIName"] = Name; Session["DIZone"] = ZoneCode; Session["DIZoneNm"] = ZoneName; Response.Redirect("~/DCA/DI/Dashboard.aspx", false); } else if (dtLogin.Rows[0]["Role"].ToString() == "2") { Session["DeoCode"] = Code; Session["DeoName"] = Name; Response.Redirect("~/DCA/DEO/CourierAck.aspx", false); } else if (dtLogin.Rows[0]["Role"].ToString() == "3") { Session["ssoCode"] = Code; Session["ssoName"] = Name; Response.Redirect("~/DCA/CodingOfficer/DashBoard.aspx", false); } else if (dtLogin.Rows[0]["Role"].ToString() == "4") { Session["UnitOfficerCode"] = Code; Session["UnitOfficerName"] = Name; Session["Labcode"] = LabCode; Session["Labname"] = LabName; Response.Redirect("~/DCA/UnitOfficer/Dashboard.aspx", false); } else if (dtLogin.Rows[0]["Role"].ToString() == "5") { Session["AnalystCode"] = Code; Session["AnalystName"] = Name; Session["Labcode"] = LabCode; Session["Labname"] = LabName; Response.Redirect("~/DCA/Analyst/AnlstDashboard.aspx", false); } else if (dtLogin.Rows[0]["Role"].ToString() == "6") { Session["JsoCode"] = Code; Session["JsoName"] = Name; Session["Labcode"] = LabCode; Session["Labname"] = LabName; Response.Redirect("~/DCA/Analyst/AnlstDashboard.aspx", false); } else { ViewState["KeyGenerator"] = Guid.NewGuid().ToString("N").Substring(0, 16); objCommon.ShowAlertMessage("Invalid Username & Password"); } } else { captch.Text = ""; ViewState["KeyGenerator"] = Guid.NewGuid().ToString("N").Substring(0, 16); objCommon.ShowAlertMessage("Please Enter Valid user name"); } } else { captch.Text = ""; ViewState["KeyGenerator"] = Guid.NewGuid().ToString("N").Substring(0, 16); lblmsg.Text = "The characters you entered didn't match.Please try again"; } } } catch (Exception ex) { ExceptionLogging.SendExcepToDB(ex, Session["UsrName"].ToString(), Request.ServerVariables["REMOTE_ADDR"].ToString()); Response.Redirect("~/Error.aspx"); } }