protected void LoginApp_Authenticate1(object sender, AuthenticateEventArgs e) { UserSessionManager userSession = new UserSessionManager(); strUserID = LoginApp.UserName.Trim(); strPassword = LoginApp.Password.Trim(); if (userSession.VerifyUser(strUserID, strPassword)) { e.Authenticated = true; FormsAuthentication.RedirectFromLoginPage(strUserID, LoginApp.RememberMeSet); } else { Session.Clear(); } }
protected void btnSave_Click(object sender, EventArgs e) { if (txtCurrentPassword.Text.Trim() == "") { ScriptManager.RegisterClientScriptBlock(btnSave, btnSave.GetType(), "save_ok", "alert('Current Password must be filled.');", true); return; } if (txtNewPassword.Text.Trim() == "") { ScriptManager.RegisterClientScriptBlock(btnSave, btnSave.GetType(), "save_ok", "alert('New Password and Confirm New Password must be filled.');", true); return; } if (txtNewPassword.Text.Trim() != txtConfirmNewPassword.Text.Trim()) { ScriptManager.RegisterClientScriptBlock(btnSave, btnSave.GetType(), "save_ok", "alert('Password and Confirm Password must match each other.');", true); return; } try { UserSessionManager objUserSessionMgr = new UserSessionManager(); if (!objUserSessionMgr.VerifyUser(UserSessionManager.LoggedOnUser.Userinfo.username, txtCurrentPassword.Text.Trim())) { ScriptManager.RegisterClientScriptBlock(btnSave, btnSave.GetType(), "save_ok", "alert('Current Password is not correct.');", true); return; } objUserSessionMgr.ChangePassword(txtCurrentPassword.Text.Trim(), txtNewPassword.Text.Trim()); txtCurrentPassword.Text = ""; txtNewPassword.Text = ""; txtConfirmNewPassword.Text = ""; ScriptManager.RegisterClientScriptBlock(btnSave, btnSave.GetType(), "save_ok", "alert('Save Success.');", true); } catch (Exception) { ScriptManager.RegisterClientScriptBlock(btnSave, btnSave.GetType(), "save_ok", "alert('Error Update Password.');", true); } }