protected void Button1_Click(object sender, EventArgs e) { if (PageValidate()) { objbe.year = objCommon.getCurrentFinancialYear(); objbe.month = DateTime.Now.Month.ToString(); objbe.season = objm.GetSeasonByMonth(objbe, ConnKey); objbe.userid = Session["UserID"].ToString(); 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()) { objbe.userid = user; objbe.pwd = txtNewPwdHash.Value; objbe.ipaddress = Request.ServerVariables["REMOTE_ADDR"].ToString(); dt = objLogin.GetLoginDetails(objbe, 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()) { Login_DL objLogin = new Login_DL(); objbe.month = DateTime.Now.Month.ToString(); objbe.season = objm.GetSeasonByMonth(objbe, ConnKey); objbe.year = objCommon.getCurrentFinancialYear(); objbe.username = txtUname.Text.Trim(); objbe.Action = "R"; 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 DistCode = dtLogin.Rows[0]["DistCode"].ToString(); string MandCode = dtLogin.Rows[0]["MandCode"].ToString(); string SPCode = dtLogin.Rows[0]["code"].ToString(); string district = dtLogin.Rows[0]["DistName"].ToString(); string mandal = dtLogin.Rows[0]["MandName"].ToString(); string roleNm = dtLogin.Rows[0]["role_name"].ToString(); string section = dtLogin.Rows[0]["section"].ToString(); string 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; objbe.username = txtUname.Text.Trim(); objbe.date_time = DateTime.Now; objbe.ipaddress = Request.ServerVariables["REMOTE_ADDR"].ToString(); objbe.loginStatus = "Login Successful"; Session["UserID"] = userid; //Session["UserID"] = objLogin.UserLoginStatus(objbe, ConnKey); //if (password.ToUpper() == "6B4C8CBCB6B66F050C12D6A0203C58A8BC6D36E5A8C28B74111681F7AECE378A") //{ // Session["Role"] = roleNm; // Session["UsrName"] = txtUname.Text; // Session["StateCode"] = StateCode; // Session["SpCode"] = SPCode; // Session["distCode"] = DistCode; // Session["mandcode"] = MandCode; // Session["district"] = district; // Session["mandal"] = mandal; // Response.Redirect("ChangePWD.aspx", false); //} //else if (dtLogin.Rows[0]["Role"].ToString() == "2") { Session["Role"] = roleNm; Session["UsrName"] = txtUname.Text; Session["StateCode"] = StateCode; Session["SpCode"] = SPCode; Session["distCode"] = DistCode; Session["mandcode"] = MandCode; Session["district"] = district; Session["mandal"] = mandal; Response.Redirect("~/Salepoint/DashBoard.aspx", false); } else if (dtLogin.Rows[0]["Role"].ToString() == "1") { Session["Role"] = roleNm; Session["UsrName"] = txtUname.Text; Session["StateCode"] = StateCode; Session["Section"] = section; Response.Redirect("~/Admin/DashBoard.aspx", false); } else if (dtLogin.Rows[0]["Role"].ToString() == "0") { Session["Role"] = roleNm; Session["UsrName"] = txtUname.Text; Session["StateCode"] = StateCode; Response.Redirect("~/SuperAdmin/Discussion.aspx", false); } else if (dtLogin.Rows[0]["Role"].ToString() == "3") { Session["Role"] = roleNm; Session["UsrName"] = txtUname.Text; Session["StateCode"] = StateCode; Session["distCode"] = DistCode; Session["district"] = district; Response.Redirect("~/DAO/Dashboard.aspx", false); } else if (dtLogin.Rows[0]["Role"].ToString() == "4") { Session["Role"] = roleNm; Session["UsrName"] = txtUname.Text; Session["StateCode"] = StateCode; Session["distCode"] = DistCode; Session["district"] = district; Session["mandcode"] = MandCode; Session["mandal"] = mandal; Response.Redirect("~/MAO/DashBoard.aspx", false); } else if (dtLogin.Rows[0]["Role"].ToString() == "5") { Session["Role"] = roleNm; Session["UsrName"] = txtUname.Text; Session["StateCode"] = StateCode; Session["distCode"] = DistCode; Session["district"] = district; Session["mandcode"] = MandCode; Session["mandal"] = mandal; Session["repid"] = dtLogin.Rows[0]["code"].ToString(); Response.Redirect("~/Rep/home.aspx", false); } else if (dtLogin.Rows[0]["Role"].ToString() == "6") { Session["Role"] = roleNm; Session["UsrName"] = txtUname.Text; Session["StateCode"] = StateCode; Session["distCode"] = DistCode; Session["district"] = district; Session["agency_id"] = dtLogin.Rows[0]["code"].ToString(); Response.Redirect("~/DM/home.aspx", false); } else if (dtLogin.Rows[0]["Role"].ToString() == "7") { Session["Role"] = roleNm; Session["UsrName"] = txtUname.Text; Session["StateCode"] = StateCode; Session["agency_id"] = dtLogin.Rows[0]["code"].ToString(); Response.Redirect("~/SM/home.aspx", false); } else if (dtLogin.Rows[0]["Role"].ToString() == "8") { Session["Role"] = roleNm; Session["UsrName"] = txtUname.Text; Session["StateCode"] = StateCode; Session["Section"] = section; Response.Redirect("~/NFSM/DashBoard.aspx", false); } } else { //captch.Text = ""; ViewState["KeyGenerator"] = Guid.NewGuid().ToString("N").Substring(0, 16); getCaptchaImage(); objCommon.ShowAlertMessage("Invalid Username & Password"); } } else { //captch.Text = ""; ViewState["KeyGenerator"] = Guid.NewGuid().ToString("N").Substring(0, 16); getCaptchaImage(); objCommon.ShowAlertMessage("Please Enter Valid user name"); } } else { //captch.Text = ""; ViewState["KeyGenerator"] = Guid.NewGuid().ToString("N").Substring(0, 16); getCaptchaImage(); 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"); } }