protected void Page_Load(object sender, EventArgs e) { LoginBLL bll = new LoginBLL(); DAL.Login login = Session["LogedInUser"] as DAL.Login; if (login != null) { bll.SetLogin(login, 2); Session.Remove("LogedInUser"); Session.Clear(); Session.RemoveAll(); GC.Collect(); Response.Redirect("Login.aspx"); } Session.Remove("LogedInUser"); Session.Clear(); Session.RemoveAll(); GC.Collect(); Response.Redirect("Login.aspx"); }
protected void btnLogin_Click(object sender, EventArgs e) { try { LoginBLL bll = new LoginBLL(); // check if the account is not locked bool? isLocked = bll.IsLocked(txtName.Text); if (isLocked == null) { //lblErrorMesage.Text = "No user found with this Name (" + txtName.Text + ")"; RadWindowManager1.RadAlert("No user found with this Name (" + txtName.Text + ")", 330, 180, "realedge associates", "alertCallBackFn"); return; } else if (isLocked.Value) { // lblErrorMesage.Text = "Your account has been blocked due to 3 failed login attempts. For unblock please contact administrator"; RadWindowManager1.RadAlert("Your account has been blocked due to 3 failed login attempts. For unblock please contact administrator", 330, 180, "realedge associates", "alertCallBackFn"); return; } // account is not locked DAL.Login model = bll.Authenticate(txtName.Text, txtPassword.Text); if (model != null) { // Password will be expire after 60 days if (model.LastPasswordReset.AddDays(60).Date <= DateTime.Now.Date) { // lblErrorMesage.Text = "Your password has been expired. Please contact administrator to reset your password"; btnResetPassword_Click(null, null); RadWindowManager1.RadAlert("Your password has been expired. We sent you new password on your email address", 330, 180, "realedge associates", "alertCallBackFn"); return; } //else if (model.IsLogin == true && model.Role != "Admin") //{ // RadWindowManager1.RadAlert("This account is already logged on.", 330, 180, "realedge associates", "alertCallBackFn"); // return; //} else { LogActivity("Login Successfull", "User Loged in successfully", string.Empty); bll.SetLogin(model, 1); Session["LogedInUser"] = model; Response.Redirect("Default.aspx"); } } else { // lblErrorMesage.Text = "Please check Name and Password. You account will be blocked after 3 unsuccessfully attempts"; LogActivity("Login Error", "Please check Name and Password. You account will be blocked after 3 unsuccessfully attempts", string.Empty); RadWindowManager1.RadAlert("Please check Name and Password. You account will be blocked after 3 unsuccessfully attempts", 330, 180, "realedge associates", "alertCallBackFn"); } } catch (Exception ex) { LogActivity("Login Error", ex.Message, string.Empty); RadWindowManager1.RadAlert(ex.Message, 330, 180, "realedge associates", "alertCallBackFn"); } }