several bugfixes

This commit is contained in:
Roman Hergenreder 2024-04-10 13:04:37 -04:00
parent 72d2850e83
commit a238ad3b7f
8 changed files with 22 additions and 11 deletions

@ -29,6 +29,7 @@ namespace Core\API\Logs {
use Core\Objects\DatabaseEntity\Group;
use Core\Objects\DatabaseEntity\SystemLog;
// TODO: how to handle pagination here for log entries stored in files?
class Get extends LogsAPI {
use Pagination;

@ -585,4 +585,9 @@ abstract class Request {
return $classes;
}
protected function logUserId(): string {
$currentUser = $this->context->getUser();
return $currentUser ? "userId='" . $currentUser->getId() . "'" : "SYSTEM";
}
}

@ -185,7 +185,6 @@ namespace Core\API\User {
$groups = [];
$sql = $this->context->getSQL();
$currentUser = $this->context->getUser();
$currentUserId = $currentUser->getId();
$requestedGroups = array_unique($this->getParam("groups"));
if (!empty($requestedGroups)) {
@ -193,8 +192,10 @@ namespace Core\API\User {
foreach ($requestedGroups as $groupId) {
if (!isset($availableGroups[$groupId])) {
return $this->createError("Group with id=$groupId does not exist.");
} else if ($groupId === Group::ADMIN && !$currentUser->hasGroup(Group::ADMIN)) {
} else if ($this->externalCall && $groupId === Group::ADMIN && !$currentUser->hasGroup(Group::ADMIN)) {
return $this->createError("You cannot create users with administrator groups.");
} else {
$groups[] = $groupId;
}
}
}
@ -205,7 +206,7 @@ namespace Core\API\User {
if ($user !== false) {
$this->user = $user;
$this->result["userId"] = $user->getId();
$this->logger->info("A new user with username='$username' and email='$email' was created by userId='$currentUserId'");
$this->logger->info("A new user with username='$username' and email='$email' was created by " . $this->logUserId());
}
return $this->success;
@ -354,7 +355,7 @@ namespace Core\API\User {
}
public static function getDefaultACL(Insert $insert): void {
$insert->addRow(self::getEndpoint(), "Allows users to search other users", [Group::ADMIN, Group::SUPPORT], true);
$insert->addRow(self::getEndpoint(), [Group::ADMIN, Group::SUPPORT], "Allows users to search other users", true);
}
}
@ -433,8 +434,7 @@ namespace Core\API\User {
return false;
}
$currentUserId = $this->context->getUser()->getId();
$this->logger->info("A new user with username='$username' and email='$email' was invited by userId='$currentUserId'");
$this->logger->info("A new user with username='$username' and email='$email' was invited by " . $this->logUserId());
// Create Token
$token = generateRandomString(36);

@ -85,7 +85,7 @@ class Settings {
public static function loadDefaults(): Settings {
$protocol = getProtocol();
$hostname = getHostName();
$hostname = getCurrentHostName();
$settings = new Settings();
// General

@ -33,6 +33,11 @@ I actually don't know what i want to implement here. There are quite to many CMS
1. `docker-compose build`
2. `docker-compose up`
3. Open the webapp in your browser and follow the installation guide
3a. Since the docker runs as user www-data (33), the following permissions are recommended and at least necessary for the installation process:
```
chown -R :33 .
chmod -R 775 .
```
### Afterwards

@ -959,7 +959,7 @@ $registeredCommands = [
"mail" => ["handler" => "onMail", "description" => "send mails and process the pipeline", "requiresDocker" => true],
"settings" => ["handler" => "onSettings", "description" => "change and view settings"],
"impersonate" => ["handler" => "onImpersonate", "description" => "create a session and print cookies and csrf tokens", "requiresDocker" => true],
"frontend" => ["handler" => "onFrontend", "description" => "build and manage frontend modules"],
"frontend" => ["handler" => "onFrontend", "description" => "build and manage frontend modules", "requiresDocker" => true],
"api" => ["handler" => "onAPI", "description" => "view and create API endpoints"],
];

@ -20,7 +20,7 @@ RUN mkdir -p /usr/local/etc/php/extra/ && \
curl -s "https://browscap.org/stream?q=Full_PHP_BrowsCapINI" -o /usr/local/etc/php/extra/browscap.ini
# NodeJS
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
RUN curl -sL https://deb.nodesource.com/setup_21.x | bash - && \
apt-get update && \
apt-get -y install nodejs && \
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | tee /usr/share/keyrings/yarnkey.gpg >/dev/null && \
@ -41,4 +41,4 @@ RUN apt-get clean
RUN if [[ ! -z "$ADDITIONAL_SCRIPT" ]]; then $ADDITIONAL_SCRIPT; fi
COPY --from=composer /usr/bin/composer /usr/bin/composer
USER www-data
USER www-data

@ -9,7 +9,7 @@ import {CircularProgress} from "@mui/material";
const StatBox = (props) => <div className={"col-lg-3 col-6"}>
<div className={"small-box bg-" + props.color}>
<div className={"inner"}>
{props.count ?
{!isNaN(props.count) ?
<>
<h3>{props.count}</h3>
<p>{props.text}</p>