本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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';