mirror of
https://github.com/Karaka-Management/oms-Admin.git
synced 2026-01-24 19:28:40 +00:00
test fixes and changes for release
This commit is contained in:
parent
9457f0dc46
commit
be564ef05c
|
|
@ -114,7 +114,7 @@
|
|||
"uri": "{/lang}/{/app}/admin/module/list",
|
||||
"target": "self",
|
||||
"icon": null,
|
||||
"order": 5,
|
||||
"order": 6,
|
||||
"from": "Admin",
|
||||
"permission": { "permission": 2, "category": null, "element": null },
|
||||
"parent": 1000101001,
|
||||
|
|
|
|||
|
|
@ -342,7 +342,7 @@ final class ApiController extends Controller
|
|||
|
||||
$mail = new Email();
|
||||
$mail->setFrom($emailSettings[SettingsEnum::MAIL_SERVER_ADDR], 'Karaka');
|
||||
$mail->addTo($account->email, \trim($account->name1 . ' ' . $account->name2 . ' ' . $account->name3));
|
||||
$mail->addTo($account->getEmail(), \trim($account->name1 . ' ' . $account->name2 . ' ' . $account->name3));
|
||||
$mail->subject = 'Karaka: Password reset';
|
||||
$mail->body = '';
|
||||
$mail->msgHTML('Your new password: <a href="' . $loginLink . '">' . $pass . '</a>'
|
||||
|
|
|
|||
|
|
@ -218,13 +218,9 @@ final class BackendController extends Controller
|
|||
$view->addData('account', $account);
|
||||
|
||||
/** @var \Modules\Admin\Models\AccountPermission[] $permissions */
|
||||
$permissions = AccountPermissionMapper::getAll()->where('account', (int) $request->getData('id'))->execute();
|
||||
|
||||
if (!isset($permissions) || $permissions instanceof NullAccountPermission) {
|
||||
$permissions = [];
|
||||
} elseif (!\is_array($permissions)) {
|
||||
$permissions = [$permissions];
|
||||
}
|
||||
$permissions = AccountPermissionMapper::getAll()
|
||||
->where('account', (int) $request->getData('id'))
|
||||
->execute();
|
||||
|
||||
$view->addData('permissions', $permissions);
|
||||
|
||||
|
|
@ -396,14 +392,10 @@ final class BackendController extends Controller
|
|||
GroupMapper::get()->with('accounts')->where('id', (int) $request->getData('id'))->execute()
|
||||
);
|
||||
|
||||
/** @var null|\Modules\Admin\Models\GroupPermission[] $permissions */
|
||||
$permissions = GroupPermissionMapper::getAll()->where('group', (int) $request->getData('id'))->execute();
|
||||
|
||||
if ($permissions === null || $permissions instanceof NullGroupPermission) {
|
||||
$permissions = [];
|
||||
} elseif (!\is_array($permissions)) {
|
||||
$permissions = [$permissions];
|
||||
}
|
||||
/** @var \Modules\Admin\Models\GroupPermission[] $permissions */
|
||||
$permissions = GroupPermissionMapper::getAll()
|
||||
->where('group', (int) $request->getData('id'))
|
||||
->execute();
|
||||
|
||||
$view->addData('permissions', $permissions);
|
||||
|
||||
|
|
@ -712,16 +704,17 @@ final class BackendController extends Controller
|
|||
|
||||
$id = $request->getData('id') ?? '';
|
||||
|
||||
/** @var \Model\Setting[] $settings */
|
||||
/** @var null|\Model\NullSetting|\Model\Setting[] $settings */
|
||||
$settings = SettingMapper::getAll()->where('module', $id)->execute();
|
||||
if (!($settings instanceof NullSetting)) {
|
||||
$view->setData('settings', !\is_array($settings) ? [$settings] : $settings);
|
||||
}
|
||||
|
||||
if ($request->getData('id') === 'Admin') {
|
||||
$view->setTemplate('/Modules/' . ($request->getData('id') ?? '') . '/Admin/Settings/Theme/Backend/settings');
|
||||
$view->setTemplate('/Modules/' . $request->getData('id') . '/Admin/Settings/Theme/Backend/settings');
|
||||
} elseif (\is_file(__DIR__ . '/../../' . ($request->getData('id') ?? '') . '/Admin/Settings/Theme/Backend/settings.tpl.php')) {
|
||||
return $this->app->moduleManager->get($request->getData('id'))->viewModuleSettings($request, $response, $data);
|
||||
return $this->app->moduleManager->get($request->getData('id') ?? '')
|
||||
->viewModuleSettings($request, $response, $data);
|
||||
} else {
|
||||
$view->setTemplate('/Modules/Admin/Theme/Backend/modules-settings');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,8 +127,14 @@ class AccountMapper extends DataMapperFactory
|
|||
*/
|
||||
public static function getWithPermissions(int $id) : Account
|
||||
{
|
||||
$account = self::get()->with('groups')->with('groups/permissions')->with('l11n')->where('id', $id)->execute();
|
||||
$groups = \array_keys($account->getGroups());
|
||||
$account = self::get()
|
||||
->with('groups')
|
||||
->with('groups/permissions')
|
||||
->with('l11n')
|
||||
->where('id', $id)
|
||||
->execute();
|
||||
|
||||
$groups = \array_keys($account->getGroups());
|
||||
|
||||
/** @var \Modules\Admin\Models\GroupPermission[] $groupPermissions */
|
||||
$groupPermissions = empty($groups)
|
||||
|
|
@ -139,17 +145,17 @@ class AccountMapper extends DataMapperFactory
|
|||
->execute();
|
||||
|
||||
foreach ($groupPermissions as $permission) {
|
||||
$account->addPermissions(\is_array($permission) ? $permission : [$permission]);
|
||||
$account->addPermission($permission);
|
||||
}
|
||||
|
||||
/** @var \Modules\Admin\Models\AccountPermission[] $accountPermission */
|
||||
/** @var \Modules\Admin\Models\AccountPermission[] $accountPermissions */
|
||||
$accountPermissions = AccountPermissionMapper::getAll()
|
||||
->where('account', $id)
|
||||
->where('element', null)
|
||||
->execute();
|
||||
|
||||
foreach ($accountPermissions as $permission) {
|
||||
$account->addPermissions(\is_array($permission) ? $permission : [$permission]);
|
||||
$account->addPermission($permission);
|
||||
}
|
||||
|
||||
return $account;
|
||||
|
|
|
|||
46
Models/NullApp.php
Normal file
46
Models/NullApp.php
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Admin\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Admin\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\Admin\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullApp extends App
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return ['id' => $this->id];
|
||||
}
|
||||
}
|
||||
|
|
@ -831,11 +831,11 @@ echo $this->getData('nav')->render(); ?>
|
|||
?>
|
||||
<tr tabindex="0" data-href="<?= $url; ?>">
|
||||
<td><?= $audit->getId(); ?>
|
||||
<td><?= $this->printHtml($audit->getModule()); ?>
|
||||
<td><?= $this->printHtml($audit->module); ?>
|
||||
<td><?= $audit->getType(); ?>
|
||||
<td><?= $this->printHtml($audit->getTrigger()); ?>
|
||||
<td><?= $this->printHtml($audit->trigger); ?>
|
||||
<td><?= $this->printHtml($audit->createdBy->login); ?>
|
||||
<td><?= $this->printHtml($audit->getRef()); ?>
|
||||
<td><?= $this->printHtml($audit->ref); ?>
|
||||
<td><?= $audit->createdAt->format('Y-m-d H:i'); ?>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($count === 0) : ?>
|
||||
|
|
|
|||
|
|
@ -323,11 +323,11 @@ echo $this->getData('nav')->render(); ?>
|
|||
$url = UriFactory::build('{/lang}/{/app}/admin/audit/single?{?}&id=' . $audit->getId()); ?>
|
||||
<tr tabindex="0" data-href="<?= $url; ?>">
|
||||
<td><?= $audit->getId(); ?>
|
||||
<td><?= $this->printHtml($audit->getModule()); ?>
|
||||
<td><?= $this->printHtml($audit->module); ?>
|
||||
<td><?= $audit->getType(); ?>
|
||||
<td><?= $this->printHtml($audit->getTrigger()); ?>
|
||||
<td><?= $this->printHtml($audit->trigger); ?>
|
||||
<td><?= $this->printHtml($audit->createdBy->login); ?>
|
||||
<td><?= $this->printHtml($audit->getRef()); ?>
|
||||
<td><?= $this->printHtml($audit->ref); ?>
|
||||
<td><?= $audit->createdAt->format('Y-m-d H:i'); ?>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($count === 0) : ?>
|
||||
|
|
|
|||
|
|
@ -57,12 +57,12 @@ echo $this->getData('nav')->render();
|
|||
$url = UriFactory::build('{/lang}/{/app}/admin/audit/single?{?}&id=' . $audit->getId()); ?>
|
||||
<tr tabindex="0" data-href="<?= $url; ?>">
|
||||
<td><?= $audit->getId(); ?>
|
||||
<td><?= $this->printHtml($audit->getModule()); ?>
|
||||
<td><?= $this->printHtml($audit->module); ?>
|
||||
<td><?= $audit->getType(); ?>
|
||||
<td><?= $this->printHtml($audit->getTrigger()); ?>
|
||||
<td><?= $this->printHtml($audit->getContent()); ?>
|
||||
<td><?= $this->printHtml($audit->trigger); ?>
|
||||
<td><?= $this->printHtml($audit->content); ?>
|
||||
<td><?= $this->printHtml($audit->createdBy->login); ?>
|
||||
<td><?= $this->printHtml($audit->getRef()); ?>
|
||||
<td><?= $this->printHtml($audit->ref); ?>
|
||||
<td><?= $audit->createdAt->format('Y-m-d H:i'); ?>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($count === 0) : ?>
|
||||
|
|
|
|||
|
|
@ -257,6 +257,25 @@ $CONFIG = [
|
|||
'root' => '/',
|
||||
'https' => false,
|
||||
],
|
||||
'app' => [
|
||||
'path' => __DIR__,
|
||||
'default' => [
|
||||
'app' => 'Backend',
|
||||
'id' => 'backend',
|
||||
'lang' => 'en',
|
||||
'theme' => 'Backend',
|
||||
'org' => 1,
|
||||
],
|
||||
'domains' => [
|
||||
'127.0.0.1' => [
|
||||
'app' => 'Backend',
|
||||
'id' => 'backend',
|
||||
'lang' => 'en',
|
||||
'theme' => 'Backend',
|
||||
'org' => 1,
|
||||
],
|
||||
],
|
||||
],
|
||||
'socket' => [
|
||||
'master' => [
|
||||
'host' => '127.0.0.1',
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ final class AccountMapperTest extends \PHPUnit\Framework\TestCase
|
|||
TestUtils::setMember($accountR, 'password', '');
|
||||
AccountMapper::update()->with('password')->execute($accountR);
|
||||
|
||||
self::assertEquals(LoginReturnType::EMPTY_PASSWORD, AccountMapper::login($accountR->login, 'orange'));
|
||||
self::assertEquals(LoginReturnType::WRONG_PASSWORD, AccountMapper::login($accountR->login, 'invalidPassword'));
|
||||
|
||||
$accountR->generatePassword('orange');
|
||||
AccountMapper::update()->with('password')->execute($accountR);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user