mirror of
https://github.com/Karaka-Management/oms-Admin.git
synced 2026-02-13 19:18:41 +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();
|
$this->app->sessionManager->save();
|
||||||
$response->set($request->uri->__toString(), new Reload());
|
$response->set($request->uri->__toString(), new Reload());
|
||||||
} elseif ($login === LoginReturnType::NOT_ACTIVATED) {
|
} 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'),
|
$this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'NOT_ACTIVATED'),
|
||||||
NotifyType::WARNING
|
null
|
||||||
));
|
);
|
||||||
} elseif ($login === LoginReturnType::WRONG_INPUT_EXCEEDED) {
|
} 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'),
|
$this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'WRONG_INPUT_EXCEEDED'),
|
||||||
NotifyType::WARNING
|
null
|
||||||
));
|
);
|
||||||
} else {
|
} 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'),
|
$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_PASS,
|
||||||
SettingsEnum::MAIL_SERVER_TLS,
|
SettingsEnum::MAIL_SERVER_TLS,
|
||||||
],
|
],
|
||||||
unit: $this->app->unitId,
|
|
||||||
module: 'Admin'
|
module: 'Admin'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -1565,9 +1579,17 @@ final class ApiController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($val = $this->validateRegistration($request))) {
|
if (!empty($val = $this->validateRegistration($request))) {
|
||||||
$response->set('account_registration', new FormValidation($val));
|
|
||||||
$response->header->status = RequestStatusCode::R_400;
|
$response->header->status = RequestStatusCode::R_400;
|
||||||
|
|
||||||
|
$this->fillJsonResponse(
|
||||||
|
$request,
|
||||||
|
$response,
|
||||||
|
NotificationLevel::ERROR,
|
||||||
|
'',
|
||||||
|
$this->app->l11nManager->getText($response->getLanguage(), 'Admin', 'Api', 'FormDataInvalid'),
|
||||||
|
$val
|
||||||
|
);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1584,6 +1606,8 @@ final class ApiController extends Controller
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($allowed->content !== '1') {
|
if ($allowed->content !== '1') {
|
||||||
|
$response->header->status = RequestStatusCode::R_400;
|
||||||
|
|
||||||
$this->fillJsonResponse(
|
$this->fillJsonResponse(
|
||||||
$request,
|
$request,
|
||||||
$response,
|
$response,
|
||||||
|
|
@ -1603,6 +1627,8 @@ final class ApiController extends Controller
|
||||||
if ($request->hasData('password')
|
if ($request->hasData('password')
|
||||||
&& \preg_match($complexity->content, (string) $request->getData('password')) !== 1
|
&& \preg_match($complexity->content, (string) $request->getData('password')) !== 1
|
||||||
) {
|
) {
|
||||||
|
$response->header->status = RequestStatusCode::R_400;
|
||||||
|
|
||||||
$this->fillJsonResponse(
|
$this->fillJsonResponse(
|
||||||
$request,
|
$request,
|
||||||
$response,
|
$response,
|
||||||
|
|
@ -1632,6 +1658,8 @@ final class ApiController extends Controller
|
||||||
&& $emailAccount->login !== null
|
&& $emailAccount->login !== null
|
||||||
&& AccountMapper::login($emailAccount->login, (string) $request->getData('password')) !== LoginReturnType::OK
|
&& AccountMapper::login($emailAccount->login, (string) $request->getData('password')) !== LoginReturnType::OK
|
||||||
) {
|
) {
|
||||||
|
$response->header->status = RequestStatusCode::R_400;
|
||||||
|
|
||||||
$this->fillJsonResponse(
|
$this->fillJsonResponse(
|
||||||
$request,
|
$request,
|
||||||
$response,
|
$response,
|
||||||
|
|
@ -1653,6 +1681,8 @@ final class ApiController extends Controller
|
||||||
&& !($loginAccount instanceof NullAccount)
|
&& !($loginAccount instanceof NullAccount)
|
||||||
&& $loginAccount->getEmail() !== $request->getData('email')
|
&& $loginAccount->getEmail() !== $request->getData('email')
|
||||||
) {
|
) {
|
||||||
|
$response->header->status = RequestStatusCode::R_400;
|
||||||
|
|
||||||
$this->fillJsonResponse(
|
$this->fillJsonResponse(
|
||||||
$request,
|
$request,
|
||||||
$response,
|
$response,
|
||||||
|
|
@ -1710,6 +1740,8 @@ final class ApiController extends Controller
|
||||||
if (empty($defaultGroupIds)
|
if (empty($defaultGroupIds)
|
||||||
&& $account->getStatus() === AccountStatus::ACTIVE
|
&& $account->getStatus() === AccountStatus::ACTIVE
|
||||||
) {
|
) {
|
||||||
|
$response->header->status = RequestStatusCode::R_400;
|
||||||
|
|
||||||
// Already set up
|
// Already set up
|
||||||
$this->fillJsonResponse(
|
$this->fillJsonResponse(
|
||||||
$request,
|
$request,
|
||||||
|
|
@ -1726,6 +1758,8 @@ final class ApiController extends Controller
|
||||||
} elseif (empty($defaultGroupIds)
|
} elseif (empty($defaultGroupIds)
|
||||||
&& $account->getStatus() === AccountStatus::INACTIVE
|
&& $account->getStatus() === AccountStatus::INACTIVE
|
||||||
) {
|
) {
|
||||||
|
$response->header->status = RequestStatusCode::R_400;
|
||||||
|
|
||||||
// Account not active
|
// Account not active
|
||||||
$this->fillJsonResponse(
|
$this->fillJsonResponse(
|
||||||
$request,
|
$request,
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class Contact
|
||||||
* @var int
|
* @var int
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private int $type = 0;
|
private int $type = ContactType::EMAIL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contact element subtype.
|
* 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;
|
namespace Modules\Admin\Models;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* App model.
|
* Data change model.
|
||||||
*
|
*
|
||||||
* @package Modules\Admin\Models
|
* @package Modules\Admin\Models
|
||||||
* @license OMS License 2.0
|
* @license OMS License 2.0
|
||||||
|
|
|
||||||
|
|
@ -13,4 +13,5 @@
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
return ['Admin' => [
|
return ['Admin' => [
|
||||||
|
'FormDataInvalid' => 'Fehlerahfte Formdaten, bitte prüfen Sie Ihre Eingabe',
|
||||||
]];
|
]];
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
return ['Admin' => [
|
return ['Admin' => [
|
||||||
|
'FormDataInvalid' => 'Form data invalid, please check your input',
|
||||||
'AccountCreateMsg' => 'Account successfully created. Link: <a href="{url}">Account</a>',
|
'AccountCreateMsg' => 'Account successfully created. Link: <a href="{url}">Account</a>',
|
||||||
'AccountCreateTitle' => 'Account',
|
'AccountCreateTitle' => 'Account',
|
||||||
'LOGIN_ERROR' => 'Login failed due to wrong login information.',
|
'LOGIN_ERROR' => 'Login failed due to wrong login information.',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user