Implement account edit; add SessionHelper, PasswordHelper and ActionResult
This commit is contained in:
parent
32add30c9d
commit
6ace072841
15 changed files with 637 additions and 68 deletions
|
|
@ -3,28 +3,31 @@ declare(strict_types=1);
|
|||
|
||||
namespace MailAccountAdmin\Common;
|
||||
|
||||
use http\Exception\RuntimeException;
|
||||
use RuntimeException;
|
||||
use MailAccountAdmin\Models\AdminUser;
|
||||
use MailAccountAdmin\Repositories\AdminUserRepository;
|
||||
|
||||
class UserHelper
|
||||
{
|
||||
/** @var SessionHelper */
|
||||
private $sessionHelper;
|
||||
/** @var AdminUserRepository */
|
||||
private $adminUserRepository;
|
||||
|
||||
public function __construct(AdminUserRepository $adminUserRepository)
|
||||
public function __construct(SessionHelper $sessionHelper, AdminUserRepository $adminUserRepository)
|
||||
{
|
||||
$this->sessionHelper = $sessionHelper;
|
||||
$this->adminUserRepository = $adminUserRepository;
|
||||
}
|
||||
|
||||
public function isLoggedIn(): bool
|
||||
{
|
||||
return !empty($_SESSION['user_id']);
|
||||
return $this->sessionHelper->getUserId() !== null;
|
||||
}
|
||||
|
||||
public function getCurrentUser(): AdminUser
|
||||
{
|
||||
$userId = $_SESSION['user_id'] ?? null;
|
||||
$userId = $this->sessionHelper->getUserId();
|
||||
if (empty($userId)) {
|
||||
throw new RuntimeException('Not logged in!');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue