當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Authenticator::assert_manager方法代碼示例

本文整理匯總了PHP中Authenticator::assert_manager方法的典型用法代碼示例。如果您正苦於以下問題:PHP Authenticator::assert_manager方法的具體用法?PHP Authenticator::assert_manager怎麽用?PHP Authenticator::assert_manager使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Authenticator的用法示例。


在下文中一共展示了Authenticator::assert_manager方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: update_programming_language

function update_programming_language($pl_id, $request)
{
    Authenticator::assert_manager($request->cookies['authToken']);
    $msg = new Messages($GLOBALS['locale']);
    try {
        $model = new Model();
        $raw_input = $request->getBody();
        $content_type = explode(';', $request->type)[0];
        if ($content_type !== 'application/json') {
            Util::output_errors_and_die('', 415);
        }
        $input_data = json_decode($raw_input, true);
        if (empty($input_data)) {
            Util::output_errors_and_die('', 400);
        }
        $result = $model->edit_programming_language($pl_id, $input_data);
        header('Content-Type: text/plain');
        http_response_code($result ? 200 : 404);
        die;
    } catch (ConflictException $e) {
        Util::output_errors_and_die($e->getMessage(), 409);
    } catch (DatabaseException $e) {
        Util::output_errors_and_die($e->getMessage(), 503);
    } catch (Exception $e) {
        Util::output_errors_and_die($e->getMessage(), 400);
    }
}
開發者ID:OrgAindaSemTitulo,項目名稱:Sistema,代碼行數:27,代碼來源:update_programming_language.php

示例2: update_user

function update_user($username, $request)
{
    $user_data = Authenticator::assert_manager($request->cookies['authToken']);
    $msg = new Messages($GLOBALS['locale']);
    try {
        $model = new Model();
        $raw_input = $request->getBody();
        $content_type = explode(';', $request->type)[0];
        switch ($content_type) {
            case 'application/json':
                $input_data = json_decode($raw_input, true);
                break;
            case 'application/x-www-form-urlencoded':
                $input_data = array();
                parse_str($raw_input, $input_data);
                break;
            default:
                Util::output_errors_and_die('', 415);
        }
        if (empty($input_data)) {
            Util::output_errors_and_die('', 400);
        }
        $changes = array();
        foreach ($input_data as $f => $v) {
            if (is_string($input_data[$f])) {
                $changes[$f] = trim($input_data[$f]);
            } else {
                Util::output_errors_and_die('', 400);
            }
        }
        if (isset($input_data['password'])) {
            // don't trim
            if (is_string($input_data['password'])) {
                $changes['password'] = $input_data['password'];
            } else {
                Util::output_errors_and_die('', 400);
            }
        }
        if ($model->update_user($username, $changes)) {
            echo $user_data['username'] . ' -> ' . $username;
            $model->insert_approvedby($user_data['username'], $username);
            http_response_code(204);
            die;
        } else {
            Util::output_errors_and_die('', 404);
        }
    } catch (DatabaseException $e) {
        Util::output_errors_and_die($e->getMessage(), 503);
    } catch (Exception $e) {
        Util::output_errors_and_die($e->getMessage(), 400);
    }
}
開發者ID:OrgAindaSemTitulo,項目名稱:Sistema,代碼行數:52,代碼來源:update_user.php

示例3: get_users

function get_users($request)
{
    Authenticator::assert_manager($request->cookies['authToken']);
    $msg = new Messages($GLOBALS['locale']);
    try {
        $model = new Model();
        $result = $model->get_users($request->query);
        http_response_code(200);
        header('Content-Type: application/json');
        echo my_json_encode($result);
        die;
    } catch (DatabaseException $e) {
        Util::output_errors_and_die($e->getMessage(), 503);
    } catch (Exception $e) {
        Util::output_errors_and_die($e->getMessage(), 400);
    }
}
開發者ID:OrgAindaSemTitulo,項目名稱:Sistema,代碼行數:17,代碼來源:get_users.php

示例4: delete_user

function delete_user($username, $request)
{
    Authenticator::assert_manager($request->cookies['authToken']);
    $msg = new Messages($GLOBALS['locale']);
    try {
        $model = new Model();
        if ($model->delete_user($username)) {
            http_response_code(204);
        } else {
            http_response_code(404);
        }
        die;
    } catch (DatabaseException $e) {
        Util::output_errors_and_die($e->getMessage(), 503);
    } catch (Exception $e) {
        Util::output_errors_and_die($e->getMessage(), 400);
    }
}
開發者ID:OrgAindaSemTitulo,項目名稱:Sistema,代碼行數:18,代碼來源:delete_user.php

示例5: test_programming_language

function test_programming_language($request)
{
    Authenticator::assert_manager($request->cookies['authToken']);
    $msg = new Messages($GLOBALS['locale']);
    try {
        $raw_input = $request->getBody();
        $content_type = explode(';', $request->type)[0];
        if ($content_type !== 'application/json') {
            Util::output_errors_and_die('', 415);
        }
        $input_data = json_decode($raw_input, true);
        if (empty($input_data)) {
            Util::output_errors_and_die('', 400);
        }
        LanguageTest::test($input_data['file_name'], $input_data['extension'], $input_data['source_code'], $input_data['compiler_flags'], $input_data['check_command'], $input_data['compile_command'], $input_data['run_command'], $input_data['arguments'], $input_data['stdin']);
    } catch (Exception $e) {
        Util::output_errors_and_die($e->getMessage(), 400);
    }
}
開發者ID:OrgAindaSemTitulo,項目名稱:Sistema,代碼行數:19,代碼來源:test_programming_language.php

示例6: get_user

function get_user($request, $username)
{
    Authenticator::assert_manager($request->cookies['authToken']);
    $msg = new Messages($GLOBALS['locale']);
    try {
        $model = new Model();
        $request->query['fields'] = implode(',', ['username', 'email', 'gender', 'full_name', 'birth_date', 'created_at', 'last_logged_in_at', 'status', 'role']);
        $request->query['username'] = $username;
        $result = $model->get_users($request->query);
        if ($result['n_items'] == 0) {
            http_response_code(404);
            die;
        }
        http_response_code(200);
        header('Content-Type: application/json');
        echo my_json_encode($result['items'][0]);
        die;
    } catch (DatabaseException $e) {
        Util::output_errors_and_die($e->getMessage(), 503);
    } catch (Exception $e) {
        Util::output_errors_and_die($e->getMessage(), 400);
    }
}
開發者ID:OrgAindaSemTitulo,項目名稱:Sistema,代碼行數:23,代碼來源:get_user.php

示例7: Messages

<?php

$msg = new Messages($GLOBALS['locale']);
Authenticator::assert_manager($_COOKIE['authToken']);
try {
    $model = new Model();
    $q = array('fields' => 'username,email,full_name,role,created_at', 'status' => 'pending-approval');
    $pending_users = $model->get_users($q);
} catch (DatabaseException $e) {
    Util::output_errors_and_die($msg->_('/showmsg/database-error'), 503);
}
include 'page.html.php';
開發者ID:OrgAindaSemTitulo,項目名稱:Sistema,代碼行數:12,代碼來源:index.php


注:本文中的Authenticator::assert_manager方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。