本文整理汇总了PHP中Authentication::authenticate方法的典型用法代码示例。如果您正苦于以下问题:PHP Authentication::authenticate方法的具体用法?PHP Authentication::authenticate怎么用?PHP Authentication::authenticate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Authentication
的用法示例。
在下文中一共展示了Authentication::authenticate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _run
protected function _run($request)
{
if ($this->requestMethod == 'POST' && count($request) == 0) {
// User tries to login
Authentication::login($_POST['username'], $_POST['password']);
if (!Authentication::authenticated()) {
Headers::sendStatusUnauthorized();
return;
} else {
Headers::sendStatusOk();
echo "login succeeded<br>";
return;
}
} else {
Authentication::authenticate();
if (!Authentication::authenticated()) {
Headers::sendStatusUnauthorized();
return;
}
if ($this->requestMethod == 'GET' && count($request) > 0) {
// User info requested
echo "requesting userinfo of user " . $request[0];
} else {
// Bad request
Headers::sendStatusMethodNotAllowed();
echo "Method not allowed<br>";
print_r($request);
}
}
}
示例2: __construct
public function __construct($request)
{
$this->_setRequestMethod();
Authentication::authenticate();
if (!Authentication::authenticated()) {
// Return unauthorised response
Headers::sendStatusUnauthorised();
echo "Unauthorised<br>";
return;
}
$this->_run($request);
}
示例3: authenticate
protected function authenticate()
{
$auth = new Authentication();
if (($user = $auth->authenticate($_POST['Login']['Username'], hash('sha512', $_POST['Login']['Password']))) !== false) {
if (!isset($_SESSION['Authenticated'])) {
$_SESSION['Authentication'] = array();
}
$_SESSION['Authentication']['User'] = $user;
$_SESSION['Authentication']['LoggedIn'] = true;
} else {
$GLOBALS['Smarty']->assign('errormessage', 'Login fehlgeschlagen');
}
}
示例4: loginSubmit
public function loginSubmit($credentials = [])
{
if (isset($credentials)) {
if ($credentials['userid'] != '') {
if ($credentials['password'] != '') {
if (Authentication::authenticate($credentials)) {
$_SESSION['userid'] = $credentials['userid'];
$_SESSION['isLogin'] = true;
header("Location: ../welcome/");
} else {
$this->flushOutput('Login failed.');
}
} else {
$this->flushOutput('Please fill Password.');
}
} else {
$this->flushOutput('Please fill ID No.');
}
}
}
示例5: dirname
*
* The second part of the query is provided by AJAX in the form of the -query- variable, containing
* whatever terms the user enters in the autocomplete field.
*/
/**
* allow for testing
*/
$debug = false;
/**
* includes
*/
require_once dirname(dirname(dirname(__FILE__))) . "/redcap_connect.php";
/**
* restricted use
*/
$userAuthenticated = Authentication::authenticate();
if ($userAuthenticated) {
/**
* get text entered by user. This is appended to query string by jquery autocomplete
*/
$full_query = $_GET['q'];
$term = prep($_GET['term']);
/**
* get field name, used to make session unique
*/
$field_name = $_GET['f'];
$query_field = $_GET['a'];
/**
* get query fragment, passed in session variable to keep prying eyes away
* results should be limited by adding LIMIT 0,n to query after $term enclosure
* if no session variable, return an appropriate error value