167 lines
4.3 KiB
PHP
167 lines
4.3 KiB
PHP
<?php
|
|
|
|
namespace BRSystems\Core\App\pubUsers;
|
|
|
|
use BRSystems\Core\App\pubUsers\inc\pubUsersController;
|
|
|
|
class pubUsers
|
|
{
|
|
public string $DIR;
|
|
public array $uriData;
|
|
public pubUsersController $controller;
|
|
|
|
public function __construct($uriData)
|
|
{
|
|
$this->uriData = $uriData;
|
|
$this->DIR = __DIR__ ?: dirname(__FILE__);
|
|
$this->controller = new pubUsersController($this->uriData, $this->DIR, basename($this->DIR));
|
|
}
|
|
|
|
/**
|
|
* Default function to run
|
|
* Skip if other callback defined
|
|
*/
|
|
public function run() {
|
|
if (!empty($this->uriData['url_alias_id'])) {
|
|
$id = (int)$this->uriData['url_alias_id'];
|
|
if ($id === pubUsersController::URL_ID_REGISTER_PAGE) {
|
|
$this->registrationAction();
|
|
return;
|
|
}
|
|
if ($id === pubUsersController::URL_ID_PROFILE_PAGE) {
|
|
$this->profileAction();
|
|
return;
|
|
}
|
|
}
|
|
|
|
$this->loginAction();
|
|
}
|
|
|
|
public function loginAction()
|
|
{
|
|
// Get action
|
|
$action = getV('a');
|
|
if (!$action) {
|
|
$action = getV('action');
|
|
}
|
|
|
|
switch ($action) {
|
|
case 'login':
|
|
sleep(1);
|
|
$this->controller->loginUser($_POST);
|
|
break;
|
|
default:
|
|
$this->controller->setLoginForm();
|
|
break;
|
|
}
|
|
}
|
|
|
|
public function passwordForceChangeAction()
|
|
{
|
|
// Get action
|
|
$action = getV('a');
|
|
if (!$action) {
|
|
$action = getV('action');
|
|
}
|
|
|
|
switch ($action) {
|
|
case 'pwd':
|
|
$this->controller->setPasswordChangeForm($_POST);
|
|
break;
|
|
default:
|
|
$this->controller->setPasswordChangeForm();
|
|
break;
|
|
}
|
|
}
|
|
|
|
public function twoFactorAuthAction()
|
|
{
|
|
// Get action
|
|
$action = getV('a');
|
|
if (!$action) {
|
|
$action = getV('action');
|
|
}
|
|
|
|
switch ($action) {
|
|
case '2fa':
|
|
sleep(1);
|
|
default:
|
|
$this->controller->set2FAForm();
|
|
break;
|
|
}
|
|
}
|
|
|
|
public function passwordRecoveryAction()
|
|
{
|
|
// Get action
|
|
$action = getV('a');
|
|
if (!$action) {
|
|
$action = getV('action');
|
|
}
|
|
|
|
switch ($action) {
|
|
case 'recovery':
|
|
$this->controller->recoveryEmail($_POST);
|
|
break;
|
|
default:
|
|
$this->controller->runPasswordRecovery();
|
|
break;
|
|
}
|
|
}
|
|
|
|
public function registrationAction()
|
|
{
|
|
$action = getV('a');
|
|
if (!$action) {
|
|
$action = getV('action');
|
|
}
|
|
|
|
switch ($action) {
|
|
case 'cna':
|
|
$this->controller->registerUser(getP('data', []));
|
|
break;
|
|
default:
|
|
$this->controller->setRegistrationForm();
|
|
break;
|
|
}
|
|
}
|
|
|
|
public function profileAction()
|
|
{
|
|
$action = getV('a');
|
|
if (!$action) {
|
|
$action = getV('action');
|
|
}
|
|
|
|
switch ($action) {
|
|
case 'profileSave':
|
|
$this->controller->saveProfile(getP('data', []));
|
|
break;
|
|
case 'pwd':
|
|
$this->controller->processProfilePasswordChange($_POST);
|
|
break;
|
|
case 'addressBookSave':
|
|
$this->controller->saveAddressBookEntry(getP('data', []));
|
|
break;
|
|
case 'addressBookDelete':
|
|
$this->controller->deleteAddressBookEntry((string)getP('address_id'));
|
|
break;
|
|
case 'addressBookSetDefault':
|
|
$this->controller->setDefaultAddressBookEntry((string)getP('address_id'), (string)getP('default_type'));
|
|
break;
|
|
case 'deleteAccount':
|
|
$this->controller->deleteAccount(getP('data', []));
|
|
break;
|
|
case 'runWishlist':
|
|
$this->controller->runWishlist();
|
|
break;
|
|
case 'wishlistPage':
|
|
$this->controller->setWishlistForm();
|
|
break;
|
|
default:
|
|
$this->controller->setProfileForm();
|
|
break;
|
|
}
|
|
}
|
|
}
|