54 lines
990 B
PHP
54 lines
990 B
PHP
<?php
|
|
|
|
require __DIR__ . '/api/config.php';
|
|
require __DIR__ . '/api/user.php';
|
|
|
|
|
|
return [
|
|
|
|
'routes' => [
|
|
[
|
|
'pattern' => 'kp/kangaworld/v1',
|
|
'method' => 'POST',
|
|
'action' => function() {
|
|
|
|
$response = array();
|
|
$response['result'] = 'false';
|
|
$response['reason'] = 'Unknown error.';
|
|
|
|
// Although Kirby only allows admins this far, we may have a
|
|
//configurable sub-role for API access later.
|
|
if (kirby()->user()->role()->id() == 'admin') {
|
|
|
|
switch (get('command')) {
|
|
|
|
case 'CONFIG_GET_CONFIG':
|
|
kpApiConfigGetConfig($response);
|
|
break;
|
|
|
|
case 'USER_CREATE':
|
|
kpApiUserCreate(get('name'), get('email'), get('password'), $response);
|
|
break;
|
|
|
|
case 'USER_GET':
|
|
kpApiUserGet(get('email'), $response);
|
|
break;
|
|
|
|
default:
|
|
$response['reason'] = 'Invalid command.';
|
|
break;
|
|
}
|
|
|
|
} else {
|
|
$response['reason'] = 'Unauthorized.';
|
|
}
|
|
|
|
return $response;
|
|
}
|
|
|
|
]
|
|
]
|
|
|
|
];
|
|
|
|
?>
|