mirror of
https://github.com/Karaka-Management/oms-Admin.git
synced 2026-01-11 13:38:39 +00:00
fix registration, login and billing
This commit is contained in:
parent
613de01454
commit
d99a802969
|
|
@ -127,20 +127,35 @@ final class ApiController extends Controller
|
|||
$this->app->sessionManager->save();
|
||||
$response->set($request->uri->__toString(), new Reload());
|
||||
} elseif ($login === LoginReturnType::NOT_ACTIVATED) {
|
||||
$response->set($request->uri->__toString(), new Notify(
|
||||
$response->header->status = RequestStatusCode::R_401;
|
||||
$this->fillJsonResponse(
|
||||
$request,
|
||||
$response,
|
||||
NotificationLevel::WARNING,
|
||||
'',
|
||||
$this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'NOT_ACTIVATED'),
|
||||
NotifyType::WARNING
|
||||
));
|
||||
null
|
||||
);
|
||||
} elseif ($login === LoginReturnType::WRONG_INPUT_EXCEEDED) {
|
||||
$response->set($request->uri->__toString(), new Notify(
|
||||
$response->header->status = RequestStatusCode::R_401;
|
||||
$this->fillJsonResponse(
|
||||
$request,
|
||||
$response,
|
||||
NotificationLevel::WARNING,
|
||||
'',
|
||||
$this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'WRONG_INPUT_EXCEEDED'),
|
||||
NotifyType::WARNING
|
||||
));
|
||||
null
|
||||
);
|
||||
} else {
|
||||
$response->set($request->uri->__toString(), new Notify(
|
||||
$response->header->status = RequestStatusCode::R_401;
|
||||
$this->fillJsonResponse(
|
||||
$request,
|
||||
$response,
|
||||
NotificationLevel::WARNING,
|
||||
'',
|
||||
$this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'LOGIN_ERROR'),
|
||||
NotifyType::WARNING
|
||||
));
|
||||
null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -192,7 +207,6 @@ final class ApiController extends Controller
|
|||
SettingsEnum::MAIL_SERVER_PASS,
|
||||
SettingsEnum::MAIL_SERVER_TLS,
|
||||
],
|
||||
unit: $this->app->unitId,
|
||||
module: 'Admin'
|
||||
);
|
||||
|
||||
|
|
@ -1565,9 +1579,17 @@ final class ApiController extends Controller
|
|||
}
|
||||
|
||||
if (!empty($val = $this->validateRegistration($request))) {
|
||||
$response->set('account_registration', new FormValidation($val));
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
|
||||
$this->fillJsonResponse(
|
||||
$request,
|
||||
$response,
|
||||
NotificationLevel::ERROR,
|
||||
'',
|
||||
$this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'FormDataInvalid'),
|
||||
$val
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1584,6 +1606,8 @@ final class ApiController extends Controller
|
|||
);
|
||||
|
||||
if ($allowed->content !== '1') {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
|
||||
$this->fillJsonResponse(
|
||||
$request,
|
||||
$response,
|
||||
|
|
@ -1603,6 +1627,8 @@ final class ApiController extends Controller
|
|||
if ($request->hasData('password')
|
||||
&& \preg_match($complexity->content, (string) $request->getData('password')) !== 1
|
||||
) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
|
||||
$this->fillJsonResponse(
|
||||
$request,
|
||||
$response,
|
||||
|
|
@ -1632,6 +1658,8 @@ final class ApiController extends Controller
|
|||
&& $emailAccount->login !== null
|
||||
&& AccountMapper::login($emailAccount->login, (string) $request->getData('password')) !== LoginReturnType::OK
|
||||
) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
|
||||
$this->fillJsonResponse(
|
||||
$request,
|
||||
$response,
|
||||
|
|
@ -1653,6 +1681,8 @@ final class ApiController extends Controller
|
|||
&& !($loginAccount instanceof NullAccount)
|
||||
&& $loginAccount->getEmail() !== $request->getData('email')
|
||||
) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
|
||||
$this->fillJsonResponse(
|
||||
$request,
|
||||
$response,
|
||||
|
|
@ -1710,6 +1740,8 @@ final class ApiController extends Controller
|
|||
if (empty($defaultGroupIds)
|
||||
&& $account->getStatus() === AccountStatus::ACTIVE
|
||||
) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
|
||||
// Already set up
|
||||
$this->fillJsonResponse(
|
||||
$request,
|
||||
|
|
@ -1726,6 +1758,8 @@ final class ApiController extends Controller
|
|||
} elseif (empty($defaultGroupIds)
|
||||
&& $account->getStatus() === AccountStatus::INACTIVE
|
||||
) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
|
||||
// Account not active
|
||||
$this->fillJsonResponse(
|
||||
$request,
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class Contact
|
|||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private int $type = 0;
|
||||
private int $type = ContactType::EMAIL;
|
||||
|
||||
/**
|
||||
* Contact element subtype.
|
||||
|
|
|
|||
36
Models/ContactType.php
Executable file
36
Models/ContactType.php
Executable file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Admin\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Admin\Models;
|
||||
|
||||
use phpOMS\Stdlib\Base\Enum;
|
||||
|
||||
/**
|
||||
* Contact type enum.
|
||||
*
|
||||
* @package Modules\Admin\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract class ContactType extends Enum
|
||||
{
|
||||
public const PHONE = 1;
|
||||
|
||||
public const FAX = 2;
|
||||
|
||||
public const WEBSITE = 3;
|
||||
|
||||
public const EMAIL = 4;
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@ declare(strict_types=1);
|
|||
namespace Modules\Admin\Models;
|
||||
|
||||
/**
|
||||
* App model.
|
||||
* Data change model.
|
||||
*
|
||||
* @package Modules\Admin\Models
|
||||
* @license OMS License 2.0
|
||||
|
|
|
|||
|
|
@ -13,4 +13,5 @@
|
|||
declare(strict_types=1);
|
||||
|
||||
return ['Admin' => [
|
||||
'FormDataInvalid' => 'Fehlerahfte Formdaten, bitte prüfen Sie Ihre Eingabe',
|
||||
]];
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
declare(strict_types=1);
|
||||
|
||||
return ['Admin' => [
|
||||
'FormDataInvalid' => 'Form data invalid, please check your input',
|
||||
'AccountCreateMsg' => 'Account successfully created. Link: <a href="{url}">Account</a>',
|
||||
'AccountCreateTitle' => 'Account',
|
||||
'LOGIN_ERROR' => 'Login failed due to wrong login information.',
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user