Accounts: Add account detail page
This commit is contained in:
parent
985f46c652
commit
4e8d879008
8 changed files with 182 additions and 5 deletions
|
|
@ -6,6 +6,7 @@ namespace MailAccountAdmin\Frontend\Accounts;
|
|||
use MailAccountAdmin\Common\UserHelper;
|
||||
use MailAccountAdmin\Frontend\BaseController;
|
||||
use MailAccountAdmin\Repositories\AccountRepository;
|
||||
use MailAccountAdmin\Repositories\AliasRepository;
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use Slim\Views\Twig;
|
||||
|
|
@ -14,11 +15,14 @@ class AccountController extends BaseController
|
|||
{
|
||||
/** @var AccountRepository */
|
||||
private $accountRepository;
|
||||
/** @var AliasRepository */
|
||||
private $aliasRepository;
|
||||
|
||||
public function __construct(Twig $view, UserHelper $userHelper, AccountRepository $accountRepository)
|
||||
public function __construct(Twig $view, UserHelper $userHelper, AccountRepository $accountRepository, AliasRepository $aliasRepository)
|
||||
{
|
||||
parent::__construct($view, $userHelper);
|
||||
$this->accountRepository = $accountRepository;
|
||||
$this->aliasRepository = $aliasRepository;
|
||||
}
|
||||
|
||||
public function showAccounts(Request $request, Response $response): Response
|
||||
|
|
@ -34,4 +38,36 @@ class AccountController extends BaseController
|
|||
|
||||
return $this->view->render($response, 'accounts.html.twig', $renderData);
|
||||
}
|
||||
|
||||
public function showAccountDetails(Request $request, Response $response, array $args): Response
|
||||
{
|
||||
// Parse URL arguments
|
||||
$accountId = (int)$args['id'];
|
||||
|
||||
// Get account data from database
|
||||
$accountData = $this->accountRepository->fetchAccountById($accountId);
|
||||
$accountUsername = $accountData['username'];
|
||||
$accountData['domain'] = explode('@', $accountUsername, 2)[1];
|
||||
|
||||
// Don't display the password hash, but at least the type of hash (used hash algorithm)
|
||||
if ($accountData['password'] === '') {
|
||||
$passwordHashType = 'empty';
|
||||
} else {
|
||||
$passwordHashInfo = password_get_info($accountData['password']);
|
||||
$passwordHashType = $passwordHashInfo['algoName'] ?? 'unknown';
|
||||
}
|
||||
|
||||
// Get list of aliases for this account
|
||||
$aliases = $this->aliasRepository->fetchAliasesForUserId($accountId);
|
||||
|
||||
$renderData = [
|
||||
'id' => $accountId,
|
||||
'accountUsername' => $accountUsername,
|
||||
'accountData' => $accountData,
|
||||
'passwordHashType' => $passwordHashType,
|
||||
'aliases' => $aliases,
|
||||
];
|
||||
|
||||
return $this->view->render($response, 'account_details.html.twig', $renderData);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue