本文整理汇总了PHP中Authenticate::getEmployeeByPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP Authenticate::getEmployeeByPassword方法的具体用法?PHP Authenticate::getEmployeeByPassword怎么用?PHP Authenticate::getEmployeeByPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Authenticate
的用法示例。
在下文中一共展示了Authenticate::getEmployeeByPassword方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preprocess
function preprocess()
{
$this->box_color = "coloredArea";
$this->msg = _("enter admin password");
// get calling class (required)
$class = isset($_REQUEST['class']) ? $_REQUEST['class'] : '';
$pos_home = MiscLib::base_url() . 'gui-modules/pos2.php';
if ($class === '' || !class_exists($class)) {
$this->change_page($pos_home);
return False;
}
// make sure calling class implements required
// method and properties
try {
$method = new ReflectionMethod($class, 'adminLoginCallback');
if (!$method->isStatic() || !$method->isPublic()) {
throw new Exception('bad method adminLoginCallback');
}
$property = new ReflectionProperty($class, 'adminLoginMsg');
if (!$property->isStatic() || !$property->isPublic()) {
throw new Exception('bad property adminLoginMsg');
}
$property = new ReflectionProperty($class, 'adminLoginLevel');
if (!$property->isStatic() || !$property->isPublic()) {
throw new Exception('bad property adminLoginLevel');
}
} catch (Exception $e) {
$this->change_page($pos_home);
return False;
}
$this->heading = $class::$adminLoginMsg;
if (isset($_REQUEST['reginput']) || isset($_REQUEST['userPassword'])) {
$passwd = '';
if (isset($_REQUEST['reginput']) && !empty($_REQUEST['reginput'])) {
$passwd = $_REQUEST['reginput'];
} else {
if (isset($_REQUEST['userPassword']) && !empty($_REQUEST['userPassword'])) {
$passwd = $_REQUEST['userPassword'];
}
}
if (strtoupper($passwd) == "CL") {
$class::adminLoginCallback(False);
$this->change_page($this->page_url . "gui-modules/pos2.php");
return False;
} else {
if (empty($passwd)) {
$this->box_color = "errorColoredArea";
$this->msg = _("re-enter admin password");
} else {
$db = Database::pDataConnect();
if (Authenticate::checkPermission($passwd, $class::$adminLoginLevel)) {
$row = Authenticate::getEmployeeByPassword($passwd);
TransRecord::add_log_record(array('upc' => $row['emp_no'], 'description' => substr($class::$adminLoginMsg . ' ' . $row['FirstName'], 0, 30), 'charflag' => 'PW', 'num_flag' => $row['emp_no']));
if (CoreLocal::get('LoudLogins') == 1) {
UdpComm::udpSend('twoPairs');
}
$result = $class::adminLoginCallback(True);
if ($result === True) {
$this->change_page(MiscLib::base_url() . 'gui-modules/pos2.php');
} else {
$this->change_page($result);
}
return False;
} else {
$this->box_color = "errorColoredArea";
$this->msg = _("re-enter admin password");
TransRecord::add_log_record(array('upc' => $passwd, 'description' => substr($class::$adminLoginMsg, 0, 30), 'charflag' => 'PW'));
if (CoreLocal::get('LoudLogins') == 1) {
UdpComm::udpSend('errorBeep');
}
}
}
}
} else {
// beep on initial page load
if (CoreLocal::get('LoudLogins') == 1) {
UdpComm::udpSend('twoPairs');
}
}
return True;
}
示例2: testAuthenticate
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));
}