private void reLoadSession() { if (Session["userType"] == null || Session["aGENT"] != null || Session["lOCATION"] != null) { USERINFO userInfo = new USERINFO(); userInfo = USERINFOManager.GetUSERINFOByUserNameType("Agent", User.Identity.Name);//"Agent" is dami in database i have not use the if (userInfo != null) { Session["userType"] = userInfo.Type.ToString(); Session["userInfoID"] = userInfo.USERINFOID.ToString(); Session["userName"] = userInfo.UserName.ToString(); //if (userInfo.Agent_LocationID.ToString() == ddlAgent.SelectedItem.Value.ToString()) if (userInfo.Type == "Agent") { Session["aGENT"] = AGENTManager.GetAGENTByID(userInfo.Agent_LocationID); Session["role"] = "Agent"; } else if (userInfo.Type == "Location") { Session["lOCATION"] = LOCATIONGROUPManager.GetLOCATIONGROUPByID(userInfo.Agent_LocationID); Session["role"] = "Location"; } } } }
protected void OnAuthenticate(object sender, AuthenticateEventArgs e) { lblMessage.Text = ""; e.Authenticated = false; Login masterLogin = (Login)masterview.FindControl("masterLogin"); string userName = masterLogin.UserName.ToString(); string password = masterLogin.Password.ToString(); //if (Membership.ValidateUser(userName, password) && (userName.Equals("admin"))) //{ // masterLogin.DestinationPageUrl = "Default.aspx"; // Session["role"] = "Admin"; // e.Authenticated = true; //} //else //{ if (Membership.ValidateUser(userName, password)) { USERINFO userInfo = new USERINFO(); userInfo = USERINFOManager.GetUSERINFOByUserNameType("Agent", userName);//"Agent" is dami in database i have not use the if (userInfo != null) { Session["userType"] = userInfo.Type.ToString(); Session["userInfoID"] = userInfo.USERINFOID.ToString(); Session["userName"] = userInfo.UserName.ToString(); e.Authenticated = true; //if (userInfo.Agent_LocationID.ToString() == ddlAgent.SelectedItem.Value.ToString()) if (userInfo.Type == "Agent") { Session["aGENT"] = AGENTManager.GetAGENTByID(userInfo.Agent_LocationID); Session["role"] = "Agent"; } else if (userInfo.Type == "Location") { Session["lOCATION"] = LOCATIONGROUPManager.GetLOCATIONGROUPByID(userInfo.Agent_LocationID); Session["role"] = "Location"; } //Response.Redirect("Default.aspx"); masterLogin.DestinationPageUrl = "~/Default.aspx"; } else { lblMessage.Text = "Password incorrect!!!"; } } else { //Response.Redirect("~/Forgetpassword.aspx"); } //} }