当前位置: 首页>>代码示例>>PHP>>正文


PHP Access::authenticate方法代码示例

本文整理汇总了PHP中Access::authenticate方法的典型用法代码示例。如果您正苦于以下问题:PHP Access::authenticate方法的具体用法?PHP Access::authenticate怎么用?PHP Access::authenticate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Access的用法示例。


在下文中一共展示了Access::authenticate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isset

<?php

require_once '../includes/config.inc';
require_once '../includes/access.inc';
$requestedUrl = isset($_REQUEST['ref']) ? base64_decode(htmlentities($_REQUEST['ref'])) : $BASE_URL . '/dashboard.php';
$submitted = isset($_REQUEST['submitted']);
$username = isset($_REQUEST['username']) ? htmlentities($_REQUEST['username']) : false;
$password = isset($_REQUEST['password']) ? htmlentities($_REQUEST['password']) : false;
$smarty = new MySmarty($SMARTY_CONFIG);
if ($submitted) {
    try {
        $access = new Access();
        if ($access->authenticate($username, $password)) {
            header("Location: " . $requestedUrl);
            exit;
        } else {
            $smarty->assign('errorMessage', 'Username or Password is incorrect. Please try logging in again.');
        }
    } catch (AccessDeniedException $e) {
        header('HTTP/1.1 401 Access Denied');
        echo "AccessDeniedException: " . $e->getMessage();
    } catch (Exception $e) {
        header('HTTP/1.1 500 Internal Server Error');
        echo "Exception: " . $e->getMessage();
    }
}
$smarty->assign('login', 'login');
$smarty->display('login.tpl');
开发者ID:kieubinh,项目名称:cs679-b1-class-project,代码行数:28,代码来源:login.php

示例2: MySmarty

<?php

require_once '../includes/config.inc';
require_once 'access.inc';
require_once 'accessdeniedexception.inc';
$smarty = new MySmarty($SMARTY_CONFIG);
try {
    $access = new Access();
    $access->authenticate(null, null, false);
    $user = $access->getUser();
    $smarty->assign('user', $user);
} catch (AccessDeniedException $e) {
    // Don't need to do anything, This just means user is not logged in.
}
$smarty->assign('left_menu', true);
$smarty->assign('about', 'about');
$smarty->display('about.tpl');
开发者ID:kieubinh,项目名称:cs679-b1-class-project,代码行数:17,代码来源:about.php

示例3: Access

<?php

require_once '../includes/config.inc';
require_once 'user.inc';
require_once 'access.inc';
require_once 'activity.inc';
require_once 'accessdeniedexception.inc';
require_once 'category.inc';
require_once 'transaction.inc';
$access = new Access();
$access->authenticate();
$user = $access->getUser();
$action = isset($_REQUEST['action']) ? htmlentities($_REQUEST['action']) : false;
$data = isset($_REQUEST['data']) ? $_REQUEST['data'] : false;
try {
    if ($action) {
        if ($data === false) {
            throw new Exception("Missing required parameter data");
        }
        switch ($action) {
            case 'edit':
                $transaction = new Transaction(new MySqlDB());
                $transaction->start();
                $activity = Factory::getView(new ActivityKey($_POST['data']['id']));
                $activity->setName($data['name']);
                if ($data['category'] != null && trim($data['category']) && $data['category'] != 'null') {
                    $activity->setCategory(Factory::getView(new CategoryKey($data['category'])));
                }
                $activity->setTransactionDate(new Date($_POST['data']['transdate']));
                $activity->setAmount($data['amount']);
                $transaction->commit();
开发者ID:kieubinh,项目名称:cs679-b1-class-project,代码行数:31,代码来源:transactions.php

示例4: Transaction

    if (!preg_match("/((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9\\s]).{8,})/", $_POST['new_password'])) {
        $smarty->assign('err_message', 'Password Invalid! Must be at least 8 characters and have one lowercase, one uppercase, one number, and one special character.');
        $smarty->display('reset_password.tpl');
    }
    try {
        $username = $_GET['username'];
        $pid = $_GET['pid'];
        $result = User::checkAuthentication($username, $pid, true);
        if ($result) {
            $transaction = new Transaction(new MySqlDB());
            $transaction->start();
            $user = User::getUserByUserName($username);
            $user->setPassword($_POST['new_password'], false);
            $transaction->commit();
            $access = new Access();
            if ($access->authenticate($username, $_POST['new_password'])) {
                header("Location: dashboard.php");
                exit;
            }
        } else {
            echo 'fff';
        }
    } catch (Exception $e) {
        if ($transaction && !$transaction->isComplete()) {
            $transaction->rollback();
        }
        header('HTTP/1.1 500 Internal Server Error');
        echo "Exception: " . $e->getMessage();
    }
} else {
    $username = $_GET['username'];
开发者ID:kieubinh,项目名称:cs679-b1-class-project,代码行数:31,代码来源:reset_password.php


注:本文中的Access::authenticate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。