public function preprocess() { $this->box_css_class = 'coloredArea'; $this->msg = _('please enter your password'); $this->body_class = ''; if (isset($_REQUEST['reginput']) || isset($_REQUEST['userPassword'])) { $passwd = ''; if (isset($_REQUEST['reginput']) && !empty($_REQUEST['reginput'])) { $passwd = $_REQUEST['reginput']; UdpComm::udpSend('goodBeep'); } elseif (isset($_REQUEST['userPassword']) && !empty($_REQUEST['userPassword'])) { $passwd = $_REQUEST['userPassword']; } if (Authenticate::checkPassword($passwd)) { Database::testremote(); $sd = MiscLib::scaleObject(); if (is_object($sd)) { $sd->ReadReset(); } /** Find a drawer for the cashier */ $my_drawer = ReceiptLib::currentDrawer(); if ($my_drawer == 0) { $available = ReceiptLib::availableDrawers(); if (count($available) > 0) { ReceiptLib::assignDrawer(CoreLocal::get('CashierNo'), $available[0]); $my_drawer = $available[0]; } } else { ReceiptLib::assignDrawer(CoreLocal::get('CashierNo'), $my_drawer); } TransRecord::addLogRecord(array('upc' => 'SIGNIN', 'description' => 'Sign In Emp#' . CoreLocal::get('CashierNo'))); /** Use Kicker object to determine whether the drawer should open The first line is just a failsafe in case the setting has not been configured. */ if (session_id() != '') { session_write_close(); } $kicker_class = CoreLocal::get("kickerModule") == "" ? 'Kicker' : CoreLocal::get('kickerModule'); $kicker_object = new $kicker_class(); if ($kicker_object->kickOnSignIn()) { ReceiptLib::drawerKick(); } if ($my_drawer == 0) { $this->change_page($this->page_url . "gui-modules/drawerPage.php"); } else { $this->change_page($this->page_url . "gui-modules/pos2.php"); } return false; } else { $this->box_css_class = 'errorColoredArea'; $this->msg = _('password invalid, please re-enter'); } } return true; }
function preprocess() { $this->color = "coloredArea"; $this->heading = _("enter password"); $this->msg = _("confirm no sales"); if (isset($_REQUEST['reginput']) || isset($_REQUEST['userPassword'])) { $passwd = ''; if (isset($_REQUEST['reginput']) && !empty($_REQUEST['reginput'])) { $passwd = $_REQUEST['reginput']; } elseif (isset($_REQUEST['userPassword']) && !empty($_REQUEST['userPassword'])) { $passwd = $_REQUEST['userPassword']; } if (strtoupper($passwd) == "CL") { $this->change_page($this->page_url . "gui-modules/pos2.php"); return False; } elseif (Authenticate::checkPassword($passwd)) { ReceiptLib::drawerKick(); if (CoreLocal::get('LoudLogins') == 1) { UdpComm::udpSend('twoPairs'); } $this->change_page($this->page_url . "gui-modules/pos2.php"); return false; } else { $this->color = "errorColoredArea"; $this->heading = _("re-enter password"); $this->msg = _("invalid password"); if (CoreLocal::get('LoudLogins') == 1) { UdpComm::udpSend('errorBeep'); } } } else { // beep on initial page load if (CoreLocal::get('LoudLogins') == 1) { UdpComm::udpSend('twoPairs'); } } return true; }
function preprocess() { $this->color = "coloredArea"; $this->img = $this->page_url . "graphics/key-icon.png"; $this->msg = _("please enter password"); if (isset($_REQUEST['reginput']) || isset($_REQUEST['scannerInput'])) { $passwd = ''; if (isset($_REQUEST['reginput']) && !empty($_REQUEST['reginput'])) { $passwd = $_REQUEST['reginput']; } elseif (isset($_REQUEST['scannerInput']) && !empty($_REQUEST['scannerInput'])) { $passwd = $_REQUEST['scannerInput']; UdpComm::udpSend('goodBeep'); } if (Authenticate::checkPassword($passwd, 4)) { $this->change_page($this->page_url . "gui-modules/pos2.php"); return False; } else { $this->color = "errorColoredArea"; $this->img = $this->page_url . "graphics/redkey4.gif"; $this->msg = _("Password Invalid, Please Re-Enter"); } } return True; }
function preprocess() { $this->hide_input(true); $dbc = Database::tDataConnect(); $q = ' SELECT MAX(paycardTransactionID) FROM PaycardTransactions WHERE transID=' . (int) CoreLocal::get('paycard_id'); $r = $dbc->query($q); if ($r && $dbc->numRows($r)) { $w = $dbc->fetchRow($r); $this->id = $w[0]; } if (!$this->id) { CoreLocal::set('boxMsg', 'Cannot locate transaction to void'); $this->change_page(MiscLib::baseURL() . 'gui-modules/boxMsg2.php'); return false; } CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_VOID); // check for posts before drawing anything, so we can redirect if (isset($_REQUEST['reginput'])) { $input = strtoupper(trim($_REQUEST['reginput'])); // CL always exits if ($input == "CL") { PaycardLib::paycard_reset(); CoreLocal::set("msgrepeat", 1); CoreLocal::set("strRemembered", 'TO'); CoreLocal::set("toggletax", 0); CoreLocal::set("togglefoodstamp", 0); $this->change_page($this->page_url . "gui-modules/pos2.php"); return false; } elseif (Authenticate::checkPassword($input)) { $this->action = "onsubmit=\"return false;\""; $this->add_onload_command("emvSubmit();"); $this->run_transaction = true; } // if we're still here, we haven't accepted a valid amount yet; display prompt again } elseif (isset($_REQUEST['xml-resp'])) { $xml = $_REQUEST['xml-resp']; $e2e = new MercuryE2E(); $json = array(); $plugin_info = new Paycards(); $json['main_frame'] = $plugin_info->pluginUrl() . '/gui/PaycardEmvSuccess.php'; $json['receipt'] = false; $success = $e2e->handleResponseDataCap($xml); if ($success === PaycardLib::PAYCARD_ERR_OK) { $json = $e2e->cleanup($json); CoreLocal::set("strEntered", ""); CoreLocal::set("strRemembered", ""); CoreLocal::set("msgrepeat", 0); if ($json['receipt']) { $json['main_frame'] .= '?receipt=' . $json['receipt']; } } else { CoreLocal::set("msgrepeat", 0); $json['main_frame'] = MiscLib::base_url() . 'gui-modules/boxMsg2.php'; } header('Location: ' . $json['main_frame']); return false; } return true; }
public function testAuthenticate() { CoreLocal::set('scaleDriver', ''); // don't interact w/ scale Database::setglobalvalue('LoggedIn', 1); Database::setglobalvalue('CashierNo', 1); $fail = Authenticate::checkPassword('9999'); $this->assertEquals(False, $fail); Database::setglobalvalue('CashierNo', 9999); $pass = Authenticate::checkPassword('9999'); $this->assertEquals(True, $pass); Database::setglobalvalue('LoggedIn', 0); Database::setglobalvalue('CashierNo', 1); $pass = Authenticate::checkPassword('9999'); $this->assertEquals(True, $pass); Database::setglobalvalue('LoggedIn', 0); Database::setglobalvalue('CashierNo', 1); $pass = Authenticate::checkPassword('56'); $this->assertEquals(True, $pass); Database::setglobalvalue('LoggedIn', 0); Database::setglobalvalue('CashierNo', 1); $fail = Authenticate::checkPassword('invalid password'); $this->assertEquals(false, $fail); $this->assertEquals(false, Authenticate::checkPermission('56', 50)); $this->assertEquals(false, Authenticate::checkPermission('56', 21)); $this->assertEquals(true, Authenticate::checkPermission('56', 20)); $this->assertEquals(true, Authenticate::checkPermission('56', 10)); $this->assertEquals(false, Authenticate::getEmployeeByPassword('asdf')); $this->assertInternalType('array', Authenticate::getEmployeeByPassword('56')); $this->assertEquals(false, Authenticate::getEmployeeByNumber(75)); $this->assertInternalType('array', Authenticate::getEmployeeByNumber(56)); $this->assertEquals(0, Authenticate::getPermission(55)); $this->assertEquals(20, Authenticate::getPermission(56)); }