protected void LoginButton_Click(object sender, EventArgs e) { try { if (Membership.ValidateUser(LoginUser.UserName, LoginUser.Password)) { FormsAuthentication.SetAuthCookie(LoginUser.UserName, false); MembershipUser user = Membership.GetUser(LoginUser.UserName); employee employee = BO_Employees.GetLoggedInEmployee(new Guid(user.ProviderUserKey.ToString())); string use = user.ToString(); // int id = employee.employee_id; rolecheck(employee.employee_id); SessionEntities se = new SessionEntities() { EmployeeID = employee.employee_id, Name = employee.fname + " " + employee.mname + " " + employee.lname, UserName = user.UserName, mobno = employee.cphone, rolename = rolename }; TextBox txtusername = (TextBox)LoginUser.FindControl("UserName"); TextBox txtpsw = (TextBox)LoginUser.FindControl("Password"); HtmlInputCheckBox chk = (HtmlInputCheckBox)LoginUser.FindControl("chkRememberM"); if (chk.Checked) { Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(30); Response.Cookies["Password"].Expires = DateTime.Now.AddDays(30); } else { Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(-1); Response.Cookies["Password"].Expires = DateTime.Now.AddDays(-1); } Response.Cookies["UserName"].Value = txtusername.Text.Trim(); Response.Cookies["Password"].Value = txtpsw.Text.Trim(); this.Session["SessionEntities"] = se; FormsAuthentication.RedirectFromLoginPage(LoginUser.UserName, false); if ((se.rolename.ToString() == "Super User") || (se.rolename.ToString() == "Appointment Setter")) { //Server.Transfer("Lead.aspx"); Response.Redirect("Lead.aspx"); } else if ((se.rolename.ToString() == "Appraiser") || (se.rolename.ToString() == "Buyer") || (se.rolename.ToString() == "Sr.Buyer") || (se.rolename.ToString() == "Sr.BuyerSuper")) { Response.Redirect("Lead.aspx"); } else if ((se.rolename.ToString() == "AutoBuyDirect")) { Response.Redirect("inventorysearchdirect.aspx"); } else { Response.Redirect("Lead.aspx"); } return; } } catch (Exception exp) { string ipaddress; ipaddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (ipaddress == "" || ipaddress == null) ipaddress = Request.ServerVariables["REMOTE_ADDR"]; string texts = ipaddress + ":IP:" + "Login.aspx"; LogDetails.LogError(texts, "LoginButton_Click:" + LoginUser.UserName + "[psw:]" + LoginUser.Password + "[<>]" + "", exp.Message.ToString()); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)