本文整理匯總了PHP中UserData::authenticate方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserData::authenticate方法的具體用法?PHP UserData::authenticate怎麽用?PHP UserData::authenticate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UserData
的用法示例。
在下文中一共展示了UserData::authenticate方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: srkRender
require_once $srkEnv->appPath . '/modules/user.php';
require_once $srkEnv->appPath . '/modules/render.php';
if ($srkEnv->reqURLLength == 1 && $srkEnv->reqMethod == 'GET') {
$srkEnv->pageTitle .= '.login';
srkRender('loginpage', array());
} elseif ($srkEnv->reqURLLength >= 2 && $srkEnv->reqURL[2] == 'edit') {
if ($srkEnv->reqMethod == 'GET') {
srkRender('loginman', array());
}
} elseif ($srkEnv->reqURLLength >= 2 && $srkEnv->reqURL[2] == 'auth') {
if ($srkEnv->reqURLLength == 2) {
$userId = $_POST['userId'];
$passwd = $_POST['passwd'];
$user = new UserData();
$user->readUser($userId);
$authRes = $user->authenticate($passwd);
if ($authRes === false) {
$_SESSION['userId'] = $user->id;
srkSend((object) array('res' => 'successful'));
} else {
srkSend((object) array('res' => $authRes));
}
} elseif ($srkEnv->reqURLLength == 3 && $srkEnv->reqURL[3] == 'register') {
$user = new UserData();
$regRes = $user->register($_POST['userId'], $_POST);
if ($regRes->res !== false) {
srkSend($regRes);
} else {
$writeRes = $user->writeUser();
if ($writeRes === false) {
$_SESSION['userId'] = $user->id;
示例2: exit
<?php
if (!defined('srkVersion')) {
exit(403);
}
require_once $srkEnv->appPath . '/modules/file.php';
require_once $srkEnv->appPath . '/modules/user.php';
require_once $srkEnv->appPath . '/modules/pen.php';
require_once $srkEnv->appPath . '/modules/render.php';
require_once $srkEnv->appPath . '/modules/cache.php';
$srkEnv->pageTitle .= '.admin';
$user = new UserData();
if (isset($_POST['userId']) && isset($_POST['passwd'])) {
$user->readUser($_POST['userId']);
$authRes = $user->authenticate($_POST['passwd']);
if ($authRes) {
srkSend((object) array('error' => $authRes));
return;
}
} else {
$user->readUser($_SESSION['userId']);
}
if ($user->status != 'normal') {
if ($srkEnv->reqMethod == 'GET') {
srkRender('error', array('error' => array('status' => '403', 'stack' => 'Access denied')));
} else {
srkSend((object) array('error' => 'Access denied'));
}
return;
} elseif ($srkEnv->reqMethod == 'GET') {
srkRender('admin', array());