示例#1
0
        protected void btn_ChangePassword_Click(object sender, System.EventArgs e)
        {
            lbl_ErrorMessage.Text = string.Empty;

            if (!(this.txtimgcode.Text == HttpContext.Current.Session["CaptchaImageText"].ToString()))
            {
                lbl_ErrorMessage.Text = ReadXML.GetGeneralMessage("IMAGE_VERIFY_FAILED", false);
                return;
            }


            if (Page.IsValid)
            {
                if (ValidateOldPassword())
                {
                    if (ValidateConfirmPassword())
                    {
                        User ThisUser = Connection.LoggedOnUser;
                        ThisUser.Password = MicroSecurity.Encrypt(txt_NewPassword.Text);

                        int ProcReturnValue = ChangePasswordManagement.GetInstance.UpdateChangePassword(ThisUser);

                        if (ProcReturnValue > (int)MicroEnums.DataOperationResult.Success)
                        {
                            lbl_ErrorMessage.Text   = string.Empty;
                            lbl_SuccessMessage.Text = ReadXML.GetSuccessMessage("PASSWORD_CHANGED");
                        }
                    }
                }
            }
        }
        private int UpdateUser()
        {
            int  ProcReturnValue = 0;
            User ThisUser        = new User();

            ThisUser.UserID   = int.Parse(PageVariables.TheUserID);
            ThisUser.Password = MicroSecurity.Encrypt(txt_ConfirmPassword.Text);
            ProcReturnValue   = UserManagement.GetInstance.UpdateUser(ThisUser);
            return(ProcReturnValue);
        }
示例#3
0
        protected void btn_Save_Click(object sender, EventArgs e)
        {
            lbl_MessageTransactionPassword.Text = string.Empty;
            try
            {
                ThisUser = Connection.LoggedOnUser;
                string UserReferenceType = Connection.LoggedOnUser.UserType;
                int    UserReferenceID   = Connection.LoggedOnUser.UserReferenceID;
                //UserReferenceType.Equals(MicroEnums.UserType.Employee.ToString());
                ThisTransactionPassword = TransactionPasswordManagement.GetInstance.GetTransactionPasswordByEmployeeID(ThisUser.UserReferenceID);

                ThisTransactionPassword.EmployeeID.Equals(UserReferenceID);
                ThisTransactionPassword.TransactionsPassword = MicroSecurity.Encrypt(txt_NewPassword.Text);
                TransactionPassword theTransactionPassword = new TransactionPassword();
                if (Page.IsValid)
                {
                    if (ValidateConfirmPassword())
                    {
                        theTransactionPassword = TransactionPasswordManagement.GetInstance.GetTransactionPasswordByEmployeeID(ThisUser.UserReferenceID);
                        if (theTransactionPassword.EmployeeID != ThisUser.UserReferenceID)
                        {
                            theTransactionPassword.EmployeeID = ThisUser.UserReferenceID;
                        }
                        theTransactionPassword.TransactionsPassword = ThisTransactionPassword.TransactionsPassword;
                        int ProcReturnValue = TransactionPasswordManagement.GetInstance.InsertTransactionPassword(theTransactionPassword);

                        if (ProcReturnValue > (int)MicroEnums.DataOperationResult.Success)
                        {
                            dialog_Message.Show();
                            lbl_TheMessage.Text = ReadXML.GetSuccessMessage("PASSWORD_SAVED");
                        }

                        else
                        {
                            theTransactionPassword.EmployeeID           = ThisUser.UserReferenceID;
                            theTransactionPassword.TransactionsPassword = ThisTransactionPassword.TransactionsPassword;
                            int ProcReturnValue1 = TransactionPasswordManagement.GetInstance.InsertTransactionPassword(theTransactionPassword);
                            if (ProcReturnValue1 > (int)MicroEnums.DataOperationResult.Success)
                            {
                                dialog_Message.Show();
                                lbl_TheMessage.Text = "Password Reset Successfully";
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                dialog_Message.Show();
                lbl_TheMessage.Text = ReadXML.GetGeneralMessage("PASSWORD_NOT_SAVE");
            }
        }
        private int SaveUser()
        {
            User objUser = new User();

            objUser.UserName        = txt_UserLogInName.Text;
            objUser.UserType        = ddl_UserType.SelectedValue;
            objUser.UserReferenceID = int.Parse(ddl_UserReferenceName.SelectedValue);
            objUser.RoleID          = int.Parse(ddl_Role.SelectedValue);
            objUser.Password        = MicroSecurity.Encrypt(txt_ConfirmPassword.Text);
            int ProcReturnValue = UserManagement.GetInstance.InsertUser(objUser);

            return(ProcReturnValue);
        }
示例#5
0
        private bool ValidateOldPassword()
        {
            bool ReturnValue = true;

            User   ThisUser         = Connection.LoggedOnUser;
            string ThisUserPassword = MicroSecurity.Decrypt(ThisUser.Password);

            if (!ThisUserPassword.Equals(txt_OldPassword.Text))
            {
                lbl_ErrorMessage.Text = ReadXML.GetFailureMessage("KO_PWD_MISMATCH");
                txt_OldPassword.Text  = string.Empty;
                txt_OldPassword.Focus();
                ReturnValue = false;
            }

            return(ReturnValue);
        }
        protected void btn_GeneratePassword_Click(object sender, EventArgs e)
        {
            if (!(this.txtimgcode.Text == HttpContext.Current.Session["CaptchaImageText"].ToString()))
            {
                lit_ErrorMessage.Text = ReadXML.GetGeneralMessage("IMAGE_VERIFY_FAILED", false);
                return;
            }

            User objUser = UserManagement.GetInstance.GetUserByLoginName(txt_UserID.Text);

            lbl_UserMessage.Text  = string.Empty;
            lit_ErrorMessage.Text = string.Empty;
            try
            {
                if (ValidateUser())
                {
                    objUser.Password            = ResetPasswordManagement.GetInstance.GeneratePassword();
                    lbl_DisplayNewPassword.Text = objUser.Password;

                    int ProcReturnValue = ResetPasswordManagement.GetInstance.ChangePassword(objUser);

                    if (ProcReturnValue > (int)MicroEnums.DataOperationResult.Success)
                    {
                    }
                    else
                    {
                        lit_ErrorMessage.Text = ReadXML.GetFailureMessage("PASSWORD_NOT_RESET");
                    }

                    objUser.Password = MicroSecurity.Encrypt(lbl_DisplayNewPassword.Text);

                    int ProcReturnValueUpdate = ChangePasswordManagement.GetInstance.UpdateChangePassword(objUser);

                    if (ProcReturnValueUpdate > (int)MicroEnums.DataOperationResult.Success)
                    {
                        lit_ErrorMessage.Text = ReadXML.GetSuccessMessage("PASSWORD_RESET");
                    }
                }
            }
            catch
            {
            }
        }
        private bool InsertUserRecord4Registration()
        {
            //throw new NotImplementedException();
            User objUser = new User();

            objUser.UserName          = txt_UserPhone.Text;
            objUser.PhoneNumber       = txt_UserPhone.Text;
            objUser.EmailAddress      = txt_UserEmail.Text;
            objUser.UserReferenceName = txt_UserFullName.Text;
            objUser.UserType          = rbList_UserType.SelectedItem.Text.ToString();
            //objUser.UserReferenceID = -4; // int.Parse(ddl_UserReferenceName.SelectedValue);
            objUser.RoleID   = int.Parse(rbList_UserType.SelectedItem.Value.ToString());
            objUser.Password = MicroSecurity.Encrypt(txt_UserPhone.Text.ToString());
            int ProcReturnValue = UserManagement.GetInstance.Insert4Registration(objUser);

            if (ProcReturnValue > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// Check the user supplied login credentials.
        /// </summary>
        /// <returns>True if user supplies valid user name and password else returns false</returns>
        public bool CheckLoginCredentials(string uid, string pwd, out User currUser)
        {
            bool          ReturnValue  = false;
            bool          LoginSuccess = true;
            User          UserInfo     = new User();
            StringBuilder sbFormMessage;

            try
            {
                // Collect the user supplied information
                UserInfo.UserName = uid; //"MLFAdmin";
                UserInfo.Password = pwd; //"Mukul";

                //UserInfo.CompanyID = ctrl_SelectDatabase.SelectedCompanyID;
                UserInfo.CompanyCode = ConfigurationManager.AppSettings["DefaultCompanyCode"].ToString();// "HO0001";

                // Get the record of the user from the database to validate against supplied data
                User CurrentUser;
                CurrentUser = UserManagement.GetInstance.GetUserByLoginName(UserInfo.UserName);
                currUser    = CurrentUser;

                sbFormMessage = new StringBuilder();

                // -----------------------------------------------------------------------------------------------
                if (CurrentUser.UserID.Equals(0) || CurrentUser == null)
                //"Login Failed! The user name doesn't exists.";
                {
                    sbFormMessage.Append("User not found");
                    LoginSuccess = false;
                }
                else if (!CurrentUser.Password.Equals(MicroSecurity.Encrypt(UserInfo.Password)))
                //"Login Failed! Incorrect password.";
                {
                    sbFormMessage.Append("Incorrect password");
                    LoginSuccess = false;
                }
                else if (string.IsNullOrEmpty(CurrentUser.CompanyID.ToString()))
                //"This user doesn't havae a company code";
                {
                    sbFormMessage.Append("No Company Identity");
                    LoginSuccess = false;
                }
                else if (CurrentUser.CompanyID.Equals(0))
                //"This user doesn't belongs to any company.";
                {
                    sbFormMessage.Append("Not associated with any company");
                    LoginSuccess = false;
                }
                // -----------------------------------------------------------------------------------------------
                else
                {
                    // A VALID USER : RETURN TRUE FOR SUCCESS
                    sbFormMessage.Append("A VALID USER");
                    LoginSuccess = true;
                }

                //// RETURN THE VALUE
                //if (!LoginSuccess)
                //{
                //    ReturnValue = false;
                //    Micro.WebApplication.MicroERP.Login.IsLoginSuccess = "NO";
                //}
                //else
                //{
                //    ReturnValue = true;
                //     Micro.WebApplication.MicroERP.Login.IsLoginSuccess = "YES";
                //}

                ReturnValue = LoginSuccess;

                return(ReturnValue);
            }
            catch (Exception ex)
            {
                currUser = null;
                return(false);
            }
            finally
            {
            }
        }
示例#9
0
        /// <summary>
        /// Check the user supplied login credentials.
        /// </summary>
        /// <returns>True if user supplies valid user name and password else returns false</returns>
        public bool CheckLoginCredentials()
        {
            bool          ReturnValue  = false;
            bool          LoginSuccess = true;
            User          UserInfo     = new User();
            StringBuilder FormMessage;

            try
            {
                // Collect the user supplied information
                UserInfo.UserName = txt_UserName.Text; //"MLFAdmin";
                UserInfo.Password = txt_Password.Text; //"Mukul";

                //Declare Login Success Global Variable and set it to false
                HttpContext.Current.Session["IsLoginSuccess"] = "NO";

                //UserInfo.CompanyID = ctrl_SelectDatabase.SelectedCompanyID;
                UserInfo.CompanyCode = ConfigurationManager.AppSettings["DefaultCompanyCode"].ToString();// "HO0001";

                // Get the record of the user from the database to validate against supplied data
                CurrentUser = UserManagement.GetInstance.GetUserByLoginName(UserInfo.UserName);
                //ThisUserOfficeTree = OfficeManagement.GetInstance.GetOfficeTreeByUserID(CurrentUser.UserID);

                // Show a message to the user after generating and HTML code in div, ul, li tag
                FormMessage = new StringBuilder("<div id='LoginErrors'><ul class='LoginFormMessage'>");

                // -----------------------------------------------------------------------------------------------
                if (CurrentUser.UserID.Equals(0) || CurrentUser == null)
                //"Login Failed! The user name doesn't exists.";
                {
                    Exception exp = Server.GetLastError();

                    LoginSuccess = false;
                    FormMessage.Append("<li>");
                    FormMessage.Append(string.Format(ReadXML.GetFailureMessage("KO_USER_NOT_EXIST"), UserInfo.UserName));
                    if (exp != null)
                    {
                        FormMessage.Append(" or ");
                        FormMessage.Append(exp.ToString());
                    }
                    FormMessage.Append("</li>");
                }
                else if (!CurrentUser.Password.Equals(MicroSecurity.Encrypt(UserInfo.Password)))
                //"Login Failed! Incorrect password.";
                {
                    LoginSuccess = false;
                    FormMessage.Append("<li>");
                    FormMessage.Append(ReadXML.GetFailureMessage("KO_PWD_MISMATCH"));
                    FormMessage.Append("</li>");
                }
                else if (string.IsNullOrEmpty(CurrentUser.CompanyID.ToString()))
                //"This user doesn't havae a company code";
                {
                    LoginSuccess = false;
                    FormMessage.Append("<li>");
                    FormMessage.Append(ReadXML.GetFailureMessage("KO_USER_NO_COMP_CODE"));
                    FormMessage.Append("</li>");
                }
                else if (CurrentUser.CompanyID.Equals(0))
                //"This user doesn't belongs to any company.";
                {
                    LoginSuccess = false;
                    FormMessage.Append("<li>");
                    FormMessage.Append(ReadXML.GetFailureMessage("KO_USER_NO_COMPANY"));
                    FormMessage.Append("</li>");
                }
                // -----------------------------------------------------------------------------------------------
                else
                {
                    // A VALID USER : RETURN TRUE FOR SUCCESS
                    LoginSuccess = true;

                    ReturnValue = true;
                    HttpContext.Current.Session["IsLoginSuccess"] = "YES";

                    // DO THE NEEDFUL AFTER SUCCESSFUL LOGIN TO THE APPLICATION
                    Micro.WebApplication.App_UserControls.UC_Login.UserLoginSuccess(true, CurrentUser);

                    //// MAINTAIN THE USERS INFORMATION
                    //SetLoggedOnUserDetails(CurrentUser);

                    //// LOAD PERMISSION/RIGHTS
                    //SetUserRolePermissions();

                    //// LOAD USER SETTINGS
                    //GetAndSetUserSettings();
                }
                FormMessage.Append("</ul></div>");

                //Show the reason
                if (!LoginSuccess)
                {
                    lit_Message.Text          = FormMessage.ToString();
                    lit_TheDialogMessage.Text = FormMessage.ToString();
                    dialog_Message.Title      = "Login Error";
                    dialog_Message.Show();
                }
                return(ReturnValue);
            }
            catch (Exception ex)
            {
                //Response.Write(ex.Message.ToString());
                lit_Message.Text          = ex.Message.ToString();
                lit_TheDialogMessage.Text = ex.Message.ToString();
                dialog_Message.Title      = "Login Error";
                dialog_Message.Show();
                //throw (new Exception("Login Error" + ex.Message.ToString()));
                return(false);
            }
            finally
            {
            }
        }
        private bool CheckLoginCredentials()
        {
            bool          ReturnValue  = false;
            bool          LoginSuccess = true;
            User          UserInfo     = new User();
            StringBuilder FormMessage;

            try
            {
                UserInfo.UserName = txt_UserName.Text;
                UserInfo.Password = txt_Password.Text;
                UserInfo.UserType = ddl_UserTye.SelectedItem.ToString();

                //UserInfo.CompanyID = ctrl_SelectDatabase.SelectedCompanyID;
                UserInfo.CompanyCode = ConfigurationManager.AppSettings["DefaultCompanyCode"].ToString();                // "HO0001";

                // Get the record of the user from the database to validate against supplied data
                CurrentUser = UserManagement.GetInstance.GetUserByLoginNameGuset(UserInfo.UserName);
                //ThisUserOfficeTree = OfficeManagement.GetInstance.GetOfficeTreeByUserID(CurrentUser.UserID);

                // Show a message to the user after generating and HTML code in div, ul, li tag
                FormMessage = new StringBuilder("<div id='LoginErrors'><ul class='LoginFormMessage'>");

                // -----------------------------------------------------------------------------------------------
                if (CurrentUser.UserID.Equals(0) || CurrentUser == null)
                //"Login Failed! The user name doesn't exists.";
                {
                    Exception exp = Server.GetLastError();

                    LoginSuccess = false;
                    FormMessage.Append("<li>");
                    FormMessage.Append(string.Format(ReadXML.GetFailureMessage("KO_USER_NOT_EXIST"), UserInfo.UserName));
                    if (exp != null)
                    {
                        FormMessage.Append(" or ");
                        FormMessage.Append(exp.ToString());
                    }
                    FormMessage.Append("</li>");
                }
                else if (!CurrentUser.Password.Equals(MicroSecurity.Encrypt(UserInfo.Password)))
                //"Login Failed! Incorrect password.";
                {
                    LoginSuccess = false;
                    FormMessage.Append("<li>");
                    FormMessage.Append(ReadXML.GetFailureMessage("KO_PWD_MISMATCH"));
                    FormMessage.Append("</li>");
                }
                else if (!CurrentUser.UserType.Equals(UserInfo.UserType))
                {
                    //"Login Failed! UserType MisMatch.";
                    LoginSuccess = false;
                    FormMessage.Append("<li>");
                    FormMessage.Append(string.Format(ReadXML.GetFailureMessage("KO_USER_NOT_EXIST"), UserInfo.UserName));
                    FormMessage.Append("</li>");
                }
                else if (string.IsNullOrEmpty(CurrentUser.CompanyID.ToString()))
                //"This user doesn't havae a company code";
                {
                    LoginSuccess = false;
                    FormMessage.Append("<li>");
                    FormMessage.Append(ReadXML.GetFailureMessage("KO_USER_NO_COMP_CODE"));
                    FormMessage.Append("</li>");
                }
                else if (CurrentUser.CompanyID.Equals(0))
                //"This user doesn't belongs to any company.";
                {
                    LoginSuccess = false;
                    FormMessage.Append("<li>");
                    FormMessage.Append(ReadXML.GetFailureMessage("KO_USER_NO_COMPANY"));
                    FormMessage.Append("</li>");
                }
                // -----------------------------------------------------------------------------------------------
                else
                {
                    // A VALID USER : RETURN TRUE FOR SUCCESS
                    LoginSuccess = true; ReturnValue = true;

                    // MAINTAIN THE USERS INFORMATION
                    SetLoggedOnUserDetails(CurrentUser);
                }
                FormMessage.Append("</ul></div>");

                //Show the reason
                if (!LoginSuccess)
                {
                    lit_Message.Text = FormMessage.ToString();
                }
                return(ReturnValue);
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message.ToString());
                lit_Message.Text = ex.Message.ToString();
                throw (new Exception("Login Error" + ex.Message.ToString()));
                return(false);
            }
            finally
            {
            }
        }