Esempio n. 1
0
        private bool UserHasAccessRights(PosisOperations OperationID)
        {
            bool userHasAccess = false;

            if (logonMode == LogonModes.UserList)
            {
                operatorId = grvUserData.GetDataRow(grvUserData.GetSelectedRows()[0])["STAFFID"].ToString();

                if (!PosApplication.Instance.BusinessLogic.UserAccessSystem.UserHasAccess(operatorId, OperationID))
                {
                    using (frmMessage dialog = new frmMessage(1322)) // Unauthorized
                    {
                        POSFormsManager.ShowPOSForm(dialog);
                    }
                }
                else
                {
                    using (frmInputNumpad frmNumPad = new frmInputNumpad())
                    {
                        frmNumPad.EntryTypes = NumpadEntryTypes.Password;
                        frmNumPad.PromptText = ApplicationLocalizer.Language.Translate(2379); //"Password";

                        do
                        {
                            POSFormsManager.ShowPOSForm(frmNumPad);
                            if (frmNumPad.DialogResult == DialogResult.OK)
                            {
                                LogonData logonData = new LogonData(PosApplication.Instance.Settings.Database.Connection, PosApplication.Instance.Settings.Database.DataAreaID);
                                password      = frmNumPad.InputText;
                                userHasAccess = logonData.ValidatePasswordHash(ApplicationSettings.Terminal.StoreId, operatorId, LogonData.ComputePasswordHash(operatorId, password, ApplicationSettings.Terminal.StaffPasswordHashName));

                                if (!userHasAccess)
                                {
                                    using (frmMessage errorMessage = new frmMessage(1325))
                                    {
                                        POSFormsManager.ShowPOSForm(errorMessage);                                         // Invalid password
                                    }

                                    frmNumPad.TryAgain();
                                }
                            }
                            else
                            {
                                break;
                            }
                        }while (!userHasAccess);
                    }
                }
            }
            else
            {
                using (ManagerAccessForm frmManager = new ManagerAccessForm(OperationID))
                {
                    POSFormsManager.ShowPOSForm(frmManager);
                    userHasAccess = DialogResult.OK == frmManager.DialogResult;
                }
            }

            return(userHasAccess);
        }
Esempio n. 2
0
        private void OnNumPadEnterButtonPressed()
        {
            if (string.IsNullOrEmpty(this.operatorId))
            {
                //
                // Read operator ID
                //
                if (string.IsNullOrEmpty(this.numUserId.EnteredValue))
                {
                    // Invalid credentials
                    using (frmMessage dialog = new frmMessage(1323, MessageBoxButtons.OK, MessageBoxIcon.Information))
                    {
                        POSFormsManager.ShowPOSForm(dialog);
                    }
                }
                else
                {
                    bool usePassword = true;

                    if (Functions.StaffBarcodeLogOn)
                    {
                        IExtendedLogOnInfo extendedLogOnInfo = new ExtendedLogOnInfo()
                        {
                            LogOnKey         = this.numUserId.EnteredValue,
                            LogOnType        = ExtendedLogOnType.Barcode,
                            PasswordRequired = Functions.StaffBarcodeLogOnRequiresPassword
                        };

                        // First see if this is a extended logon key
                        this.operatorId = PosApplication.Instance.Services.Peripherals.LogOnDevice.Identify(extendedLogOnInfo);

                        // If not found, then give a try to legacy barcode mask approch.
                        if (string.IsNullOrWhiteSpace(operatorId))
                        {
                            IBarcodeInfo barcodeInfo = PosApplication.Instance.Services.Barcode.ProcessBarcode(BarcodeEntryType.ManuallyEntered, this.numUserId.EnteredValue);

                            if (barcodeInfo.InternalType == BarcodeInternalType.Employee)
                            {
                                this.operatorId = barcodeInfo.EmployeeId;
                            }
                        }

                        if (!string.IsNullOrWhiteSpace(operatorId))
                        {
                            usePassword = extendedLogOnInfo.PasswordRequired;
                        }
                    }

                    if (string.IsNullOrWhiteSpace(operatorId))
                    {
                        this.operatorId = this.numUserId.EnteredValue;    //Standard employee id
                    }

                    if (usePassword)
                    {
                        PromptForPassword();
                    }
                    else
                    {
                        ValidateCredentials(ApplicationSettings.Terminal.StoreId, this.operatorId, null);
                    }
                }
            }
            else
            {
                //
                // Read password
                //
                using (SecureString ss = new SecureString())
                {
                    foreach (char c in this.numUserId.EnteredValue)
                    {
                        ss.AppendChar(c);
                    }

                    ss.MakeReadOnly();

                    ValidateCredentials(ApplicationSettings.Terminal.StoreId, this.operatorId, LogonData.ComputePasswordHash(this.operatorId, ss, ApplicationSettings.Terminal.StaffPasswordHashName));
                }
            }
        }