This commit is contained in:
Dennis Eichhorn 2018-12-08 21:48:43 +01:00
parent 1aecdf40be
commit f0f27abbf2
4 changed files with 53 additions and 2 deletions

View File

@ -151,7 +151,7 @@ class Installer extends InstallerAbstract
`account_id` int(11) NOT NULL AUTO_INCREMENT,
`account_status` tinyint(2) NOT NULL,
`account_type` tinyint(2) NOT NULL,
`account_login` varchar(30) NOT NULL,
`account_login` varchar(50) NOT NULL,
`account_name1` varchar(50) NOT NULL,
`account_name2` varchar(50) NOT NULL,
`account_name3` varchar(50) NOT NULL,
@ -163,6 +163,7 @@ class Installer extends InstallerAbstract
`account_localization` int(11) DEFAULT NULL,
`account_created_at` datetime NOT NULL,
PRIMARY KEY (`account_id`),
UNIQUE KEY `account_login` (`account_login`),
KEY `account_localization` (`account_localization`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
)->execute();

View File

@ -41,6 +41,8 @@ use phpOMS\Account\PermissionAbstract;
use phpOMS\Account\PermissionOwner;
use phpOMS\Validation\Network\Email;
use Model\Settings;
/**
* Admin controller class.
*
@ -436,6 +438,21 @@ final class ApiController extends Controller
$account,
]);
if (((string) ($request->getData('password') ?? '')) !== ''
&& ((string) ($request->getData('login') ?? '')) !== ''
) {
$this->app->moduleManager->get('Profile')->apiProfileCreateDbEntry(new \Modules\Profile\Models\Profile($account));
$this->app->eventManager->trigger('PRE:Module:Admin-account-update', '', $account);
$account->setLoginTries((int) $this->app->appSettings->get(Settings::LOGIN_TRIES));
AccountMapper::update($account);
$this->app->eventManager->trigger('POST:Module:Admin-account-update', '', [
$request->getHeader()->getAccount(),
null,
$account,
]);
}
$response->getHeader()->set('Content-Type', MimeType::M_JSON, true);
$response->set($request->getUri()->__toString(), [
'status' => NotificationLevel::OK,

View File

@ -24,4 +24,37 @@ namespace Modules\Admin\Models;
*/
class Account extends \phpOMS\Account\Account
{
/**
* Remaining login tries.
*
* @var int
* @since 1.0.0
*/
protected $tries = 0;
/**
* Get remaining login tries
*
* @return int
*
* @since 1.0.0
*/
public function getLoginTries() : int
{
return $this->tries;
}
/**
* Set remaining login tries
*
* @param int $tries Remaining login tries
*
* @return void
*
* @since 1.0.0
*/
public function setLoginTries(int $tries = 0) : void
{
$this->tries = $tries;
}
}

View File

@ -47,7 +47,7 @@ final class AccountMapper extends DataMapperAbstract
'account_name3' => ['name' => 'account_name3', 'type' => 'string', 'internal' => 'name3', 'autocomplete' => true],
'account_password' => ['name' => 'account_password', 'type' => 'string', 'internal' => 'password'],
'account_email' => ['name' => 'account_email', 'type' => 'string', 'internal' => 'email', 'autocomplete' => true],
//'account_tries' => ['name' => 'account_tries', 'type' => 'int', 'internal' => 'tries'],
'account_tries' => ['name' => 'account_tries', 'type' => 'int', 'internal' => 'tries'],
'account_lactive' => ['name' => 'account_lactive', 'type' => 'DateTime', 'internal' => 'lastActive'],
'account_created_at' => ['name' => 'account_created_at', 'type' => 'DateTime', 'internal' => 'createdAt'],
];