first commit
This commit is contained in:
101
bundles/KupShop/UserBundle/View/LoginResetNewPasswordView.php
Normal file
101
bundles/KupShop/UserBundle/View/LoginResetNewPasswordView.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: ondra
|
||||
* Date: 8.8.17
|
||||
* Time: 14:03.
|
||||
*/
|
||||
|
||||
namespace KupShop\UserBundle\View;
|
||||
|
||||
use KupShop\KupShopBundle\Context\UserContext;
|
||||
use KupShop\KupShopBundle\Util\Contexts;
|
||||
use KupShop\KupShopBundle\Views\Traits\RequestTrait;
|
||||
use KupShop\KupShopBundle\Views\View;
|
||||
|
||||
class LoginResetNewPasswordView extends View
|
||||
{
|
||||
use RequestTrait;
|
||||
|
||||
protected $template = 'login.reset.tpl';
|
||||
|
||||
public function getBodyVariables()
|
||||
{
|
||||
if (Contexts::get(UserContext::class)->isActive()) {
|
||||
redirection('INDEX');
|
||||
}
|
||||
|
||||
$vars = parent::getBodyVariables();
|
||||
$vars['act'] = 'get_new';
|
||||
|
||||
if (!$this->check()) { // check if token is not expired
|
||||
redirection(createScriptURL([
|
||||
'URL' => 'launch.php',
|
||||
's' => 'login',
|
||||
]));
|
||||
}
|
||||
|
||||
if ($this->request->get('passSubmit') != null) {
|
||||
$this->submitChange();
|
||||
}
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
public function submitChange()
|
||||
{
|
||||
$user = \User::createFromId($this->request->get('id'));
|
||||
|
||||
$passw = $this->request->get('password');
|
||||
$passwordAgain = $this->request->get('passwordAgain');
|
||||
if ($passw == $passwordAgain) {
|
||||
$user->updatePassword($passw);
|
||||
addUserMessage(translate('errorPassw', 'login')['email_sent'], 'success');
|
||||
redirection(createScriptURL([
|
||||
'URL' => 'launch.php',
|
||||
's' => 'login',
|
||||
'error' => '6',
|
||||
'ESCAPE' => 'NO',
|
||||
]));
|
||||
} else {
|
||||
addUserMessage(translate('errorPassw', 'login')['not_same']);
|
||||
}
|
||||
}
|
||||
|
||||
public function check()
|
||||
{
|
||||
$user = \User::createFromId($this->request->get('id'));
|
||||
if ($user) {
|
||||
$requestHash = $this->request->get('request');
|
||||
$hashMatch = false;
|
||||
// zkusit posledni 3 dny
|
||||
foreach (range(0, 2) as $day) {
|
||||
$date = new \DateTime();
|
||||
$hash = $user->getChangePasswordHash(
|
||||
$date->sub(new \DateInterval('P'.$day.'D'))
|
||||
);
|
||||
|
||||
if ($hash == $requestHash) {
|
||||
$hashMatch = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($hashMatch) {
|
||||
return true;
|
||||
} else {
|
||||
addUserMessage(translate('errorPassw', 'login')['link_expirated']);
|
||||
}
|
||||
} else {
|
||||
addUserMessage(translate('errorPassw', 'login')['link_expirated']);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return translate('title', 'user.password');
|
||||
}
|
||||
}
|
||||
70
bundles/KupShop/UserBundle/View/LoginResetSendEmailView.php
Normal file
70
bundles/KupShop/UserBundle/View/LoginResetSendEmailView.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\UserBundle\View;
|
||||
|
||||
use KupShop\KupShopBundle\Context\UserContext;
|
||||
use KupShop\KupShopBundle\Email\PasswordResetEmail;
|
||||
use KupShop\KupShopBundle\Util\Contexts;
|
||||
use KupShop\KupShopBundle\Views\Traits\RequestTrait;
|
||||
use KupShop\KupShopBundle\Views\View;
|
||||
|
||||
class LoginResetSendEmailView extends View
|
||||
{
|
||||
use RequestTrait;
|
||||
|
||||
protected $template = 'login.reset.tpl';
|
||||
|
||||
protected $emailService;
|
||||
|
||||
public function __construct(PasswordResetEmail $emailService)
|
||||
{
|
||||
$this->emailService = $emailService;
|
||||
}
|
||||
|
||||
public function getBodyVariables()
|
||||
{
|
||||
if (Contexts::get(UserContext::class)->isActive()) {
|
||||
redirection('INDEX');
|
||||
}
|
||||
|
||||
$vars = parent::getBodyVariables();
|
||||
|
||||
$vars['act'] = 'passw';
|
||||
|
||||
// if form was send
|
||||
if ($this->request->get('emailSubmit') != null) {
|
||||
$this->emailSubmit($this->request->get('email'));
|
||||
}
|
||||
|
||||
// $vars['errorPassw'] = $this->getError();
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
public function emailSubmit($email)
|
||||
{
|
||||
// if email field is not empty
|
||||
if ($email != null) {
|
||||
$user = \User::createFromLogin($email);
|
||||
|
||||
if ($user) {
|
||||
$this->emailService->setUser($user);
|
||||
$message = $this->emailService->getEmail();
|
||||
$message['to'] = $user['email'];
|
||||
$this->emailService->sendEmail($message);
|
||||
}
|
||||
/*
|
||||
* Vypsání 'succes' msg VŽDY je z důvodu bezpečnosti, jelikož nechceme vypisovat informaci o tom, jestli uživatel
|
||||
* není v databázi nebo je registrovaný - řešeno v tiketu #17395
|
||||
* */
|
||||
addUserMessage(translate('errorPassw', 'login')['email_confirm'], 'success');
|
||||
} else {
|
||||
addUserMessage(translate('errorPassw', 'login')['not_all_valid']);
|
||||
}
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return translate('user.password', 'title');
|
||||
}
|
||||
}
|
||||
82
bundles/KupShop/UserBundle/View/LoginView.php
Normal file
82
bundles/KupShop/UserBundle/View/LoginView.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\UserBundle\View;
|
||||
|
||||
use KupShop\KupShopBundle\Context\UserContext;
|
||||
use KupShop\KupShopBundle\Util\Contexts;
|
||||
use KupShop\KupShopBundle\Views\Traits\RequestTrait;
|
||||
use KupShop\KupShopBundle\Views\View;
|
||||
use Symfony\Component\Security\Core\Exception\CustomUserMessageAuthenticationException;
|
||||
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
||||
|
||||
class LoginView extends View
|
||||
{
|
||||
use \DatabaseCommunication;
|
||||
use RequestTrait;
|
||||
|
||||
/** @var AuthenticationUtils */
|
||||
private $authenticationUtils;
|
||||
|
||||
protected $template = 'login.tpl';
|
||||
|
||||
public function __construct(AuthenticationUtils $authenticationUtils)
|
||||
{
|
||||
$this->authenticationUtils = $authenticationUtils;
|
||||
}
|
||||
|
||||
public function getBreadcrumbs()
|
||||
{
|
||||
return getReturnNavigation(-1, 'NO_TYPE', [translate('returnNav', 'login')]);
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return translate('title', 'login');
|
||||
}
|
||||
|
||||
public function getBodyVariables()
|
||||
{
|
||||
$vars = parent::getBodyVariables();
|
||||
|
||||
if (Contexts::get(UserContext::class)->isActive()) {
|
||||
redirection('INDEX');
|
||||
}
|
||||
|
||||
if ($this->getAct() == 'passw') {
|
||||
redirection(createScriptURL([
|
||||
'URL' => 'launch.php',
|
||||
's' => 'login.reset',
|
||||
'act' => 'passw',
|
||||
]));
|
||||
}
|
||||
|
||||
if ($lastError = $this->authenticationUtils->getLastAuthenticationError()) {
|
||||
// podpora pro custom message kdyz zfailuje login
|
||||
if ($lastError instanceof CustomUserMessageAuthenticationException) {
|
||||
$this->addErrorMessage($lastError->getMessage());
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
$userEmail = $this->authenticationUtils->getLastUsername();
|
||||
$user = $this->selectSQL('users', ['email' => $userEmail])->fetch();
|
||||
if ($user && $user['figure'] === 'Y' && empty($user['passw'])) {
|
||||
$this->addErrorMessage(replacePlaceholders(
|
||||
translate('errorPassw', 'login')['email_confirm_newpass'],
|
||||
['URL' => path('kupshop_user_loginreset_sendemail')]
|
||||
));
|
||||
} elseif (class_exists('KupShop\UserOauthBundle\Security\ClientIDNotFoundException') && $lastError instanceof \KupShop\UserOauthBundle\Security\ClientIDNotFoundException) {
|
||||
$this->addErrorMessage(translate('oauth', 'login')['unknown_clientid_with_known_email']);
|
||||
} else {
|
||||
$this->addErrorMessage(translate('error', 'login')['false_login']);
|
||||
}
|
||||
}
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
public function getAct()
|
||||
{
|
||||
return $this->request->get('act');
|
||||
}
|
||||
}
|
||||
15
bundles/KupShop/UserBundle/View/LogoutView.php
Normal file
15
bundles/KupShop/UserBundle/View/LogoutView.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\UserBundle\View;
|
||||
|
||||
use KupShop\KupShopBundle\Views\View;
|
||||
|
||||
class LogoutView extends View
|
||||
{
|
||||
protected $template = 'logout.tpl';
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return translate('title', 'logout');
|
||||
}
|
||||
}
|
||||
61
bundles/KupShop/UserBundle/View/PasswordView.php
Normal file
61
bundles/KupShop/UserBundle/View/PasswordView.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\UserBundle\View;
|
||||
|
||||
use KupShop\KupShopBundle\Views\View;
|
||||
use KupShop\UserBundle\Security\LegacyPasswordEncoder;
|
||||
|
||||
class PasswordView extends View
|
||||
{
|
||||
protected $template = 'user.password.tpl';
|
||||
|
||||
protected $encoder;
|
||||
|
||||
public function __construct(LegacyPasswordEncoder $encoder)
|
||||
{
|
||||
if (!\User::getCurrentUser()) {
|
||||
redirection('LOGIN');
|
||||
}
|
||||
|
||||
$this->encoder = $encoder;
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return translate('title', 'user.password');
|
||||
}
|
||||
|
||||
public function getBodyVariables()
|
||||
{
|
||||
if (getVal('acn') == 'changePassword') {
|
||||
$this->handleChangePassword();
|
||||
}
|
||||
|
||||
return parent::getBodyVariables();
|
||||
}
|
||||
|
||||
public function handleChangePassword()
|
||||
{
|
||||
$user = \User::getCurrentUser();
|
||||
|
||||
$oldPassword = getVal('oldPassword');
|
||||
if ($user->passw != '' && $oldPassword !== null) {
|
||||
if (!$this->encoder->isPasswordValid($user->passw, $oldPassword, '')) {
|
||||
$this->addErrorMessage(translate('passwordChangeErrorNoMatch', 'user.password'));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$newPassword = getVal('newPassword');
|
||||
if ($user->sanitizePassword($newPassword)) {
|
||||
$this->addErrorMessage(translate('passwordChangeErrorWeak', 'user.password'));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$user->updatePassword($newPassword);
|
||||
|
||||
$this->addSuccessMessage(translate('passwordChanged', 'user.password'));
|
||||
}
|
||||
}
|
||||
501
bundles/KupShop/UserBundle/View/UserView.php
Normal file
501
bundles/KupShop/UserBundle/View/UserView.php
Normal file
@@ -0,0 +1,501 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\UserBundle\View;
|
||||
|
||||
use KupShop\ContentBundle\Util\Captcha;
|
||||
use KupShop\ContentBundle\View\Exception\ValidationException;
|
||||
use KupShop\GraphQLBundle\EventListener\JsShopRefreshListener;
|
||||
use KupShop\KupShopBundle\Context\UserContext;
|
||||
use KupShop\KupShopBundle\Email\UserRegisterEmail;
|
||||
use KupShop\KupShopBundle\Exception\RedirectException;
|
||||
use KupShop\KupShopBundle\Util\Contexts;
|
||||
use KupShop\KupShopBundle\Util\Mail\EmailCheck;
|
||||
use KupShop\KupShopBundle\Views\Traits\RequestTrait;
|
||||
use KupShop\KupShopBundle\Views\View;
|
||||
use KupShop\OrderingBundle\Util\VIES\DICValidator;
|
||||
use KupShop\UserBundle\Util\UserConsent;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
|
||||
class UserView extends View
|
||||
{
|
||||
use RequestTrait;
|
||||
|
||||
protected string $smartyFallback = 'account';
|
||||
protected string $entrypoint = 'account';
|
||||
|
||||
protected $template = 'user.tpl';
|
||||
|
||||
private $type;
|
||||
|
||||
protected $user;
|
||||
|
||||
protected $register;
|
||||
|
||||
protected $error;
|
||||
|
||||
public function __construct(
|
||||
protected UserConsent $userConsent,
|
||||
protected EmailCheck $emailCheck,
|
||||
protected DICValidator $DICValidator,
|
||||
protected UserRegisterEmail $email,
|
||||
protected SessionInterface $session,
|
||||
protected RequestStack $requestStack,
|
||||
) {
|
||||
$this->user = new \User();
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
if ($this->newUser()) {
|
||||
return translate('title', 'user')[0];
|
||||
}
|
||||
|
||||
return translate('title', 'user')[1];
|
||||
}
|
||||
|
||||
public function getBreadcrumbs()
|
||||
{
|
||||
if ($this->newUser()) {
|
||||
return getReturnNavigation(-1, 'NO_TYPE', [translate('title', 'user')[0]]);
|
||||
}
|
||||
|
||||
return getReturnNavigation(-1, 'USER', [translate('title', 'user')[1]]);
|
||||
}
|
||||
|
||||
public function getBodyVariables()
|
||||
{
|
||||
$vars = parent::getBodyVariables();
|
||||
|
||||
if ($this->newUser()) {
|
||||
$vars['newUser'] = true;
|
||||
}
|
||||
|
||||
if ($this->request->get('Submit')) {
|
||||
$this->handleSubmit();
|
||||
}
|
||||
|
||||
// data to template
|
||||
if (!$this->newUser() || $this->request->get('Submit')) {
|
||||
$data = $this->getData();
|
||||
foreach ($data as $key => $value) {
|
||||
$vars['input'][$key] = ['value' => $value];
|
||||
}
|
||||
}
|
||||
|
||||
$vars['input']['news'] = getVal('news', null, $this->newUser() == true ? 'N' : $data['news']);
|
||||
$vars['input']['password']['value'] = '';
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
private function addFieldsToInvoice($invoice, $fields)
|
||||
{
|
||||
foreach ($fields as $field) {
|
||||
$invoice[$field] = getVal($field);
|
||||
}
|
||||
|
||||
return $invoice;
|
||||
}
|
||||
|
||||
protected function getInvoice()
|
||||
{
|
||||
$fields = \User::getFields();
|
||||
$invoice = [];
|
||||
foreach ($fields as $field) {
|
||||
$invoice[$field] = getVal($field);
|
||||
}
|
||||
|
||||
return $invoice;
|
||||
}
|
||||
|
||||
protected function getDelivery()
|
||||
{
|
||||
$fields = \User::getFields();
|
||||
$delivery = [];
|
||||
foreach ($fields as $field) {
|
||||
$delivery[$field] = getVal('d'.$field);
|
||||
}
|
||||
|
||||
return $delivery;
|
||||
}
|
||||
|
||||
protected function sendConfirmEmail(\User $user)
|
||||
{
|
||||
$this->email->setUser($user);
|
||||
$message = $this->email->getEmail();
|
||||
$message['to'] = $user->email;
|
||||
|
||||
return $this->email->sendEmail($message);
|
||||
}
|
||||
|
||||
protected function handleSubmit(): void
|
||||
{
|
||||
$invoice = $this->getInvoice();
|
||||
$invoice = $this->addFieldsToInvoice($invoice, ['email', 'ico', 'dic', 'phone', 'transport', 'gender', 'birthdate', 'copy_email']);
|
||||
$delivery = $this->getDelivery();
|
||||
$password = getVal('password');
|
||||
$newsletter = getVal('news', null, 'N');
|
||||
foreach (getVal('custom_data', null, []) as $key => $value) {
|
||||
$this->user->setCustomData($key, $value);
|
||||
}
|
||||
|
||||
if ($this->newUser()) {
|
||||
if ($invoice['email'] && $this->emailCheck->isEmailDomainValid($invoice['email'])) {
|
||||
if ($this->checkCaptcha()) {
|
||||
// check DIC
|
||||
$error = false;
|
||||
if (findModule(\Modules::ORDERS, \Modules::SUB_DIC_VALIDATE)) {
|
||||
if (!empty($invoice['dic'])) {
|
||||
if (!$this->DICValidator->checkVat($invoice['dic'])) {
|
||||
addUserMessage(translate('invalid_dic', 'order_error'), 'danger');
|
||||
$error = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
// transakce kvuli master / slave
|
||||
$user = sqlGetConnection()->transactional(function () use ($invoice, $delivery, $password, $newsletter) {
|
||||
$id = $this->registerUser($invoice, $delivery, $password);
|
||||
if (!$id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// newsletter save
|
||||
$this->userConsent->updateNewsletter($id, $newsletter, $this->newUser(), $this->isNewsletterConfirmed());
|
||||
|
||||
// login user
|
||||
$userObject = \User::createFromId($id);
|
||||
$userObject->login(getUserKey());
|
||||
|
||||
return $userObject;
|
||||
});
|
||||
|
||||
if ($user) {
|
||||
// send confirm email
|
||||
$this->sendConfirmEmail($user);
|
||||
|
||||
// redirect on homepage
|
||||
addUserMessage(translate('registerSucceeded', 'user'), 'success');
|
||||
$this->requestStack->getMainRequest()->attributes->set('gtm_registration', [
|
||||
'email' => $invoice['email'],
|
||||
'firstname' => $invoice['name'],
|
||||
]);
|
||||
|
||||
if (findModule(\Modules::JS_SHOP)) {
|
||||
$this->session->set(JsShopRefreshListener::SESSION_NAME, true);
|
||||
}
|
||||
|
||||
$path = $this->request->get('redirect') ? $this->request->get('redirect') : path('account');
|
||||
throw new RedirectException($path);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
addUserMessage(sprintf(translate('error', 'user')['invalid_email_domain'], htmlentities($invoice['email'])));
|
||||
}
|
||||
} else {
|
||||
$oldUserEmail = \User::getCurrentUser()->email;
|
||||
|
||||
// update
|
||||
$id = $this->updateUser($invoice, $delivery);
|
||||
if ($id) {
|
||||
// newsletter save
|
||||
$this->userConsent->updateNewsletter($id, $newsletter, $this->newUser(), $this->isNewsletterConfirmed());
|
||||
|
||||
// password update
|
||||
if (!empty($password)) {
|
||||
$this->user->updatePassword($password);
|
||||
}
|
||||
|
||||
if (!empty($password) || $oldUserEmail != $invoice['email']) {
|
||||
// relogin user, otherwise it might not be recognized on the next request
|
||||
$userObject = \User::createFromId($id);
|
||||
$userObject->login(getUserKey());
|
||||
}
|
||||
|
||||
addUserMessage(translate('error', 'user')['saved'], 'success');
|
||||
// redirect on homepage
|
||||
redirection('REFERER');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function getData()
|
||||
{
|
||||
$id_user = Contexts::get(UserContext::class)->getActiveId();
|
||||
$data = [];
|
||||
$qb = sqlQueryBuilder()->select('*')
|
||||
->from('users')
|
||||
->where('id=:id')->setParameter('id', $id_user)->execute();
|
||||
if ($qb->rowCount() == 1) {
|
||||
$user = $qb->fetch();
|
||||
$data = $this->fetchUserData($data, $user);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
// collect post data
|
||||
foreach ($this->request->request->all() as $name => $value) {
|
||||
$data[$name] = $value;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function checkPassword($password, $passwordAgain)
|
||||
{
|
||||
if ($password == $passwordAgain) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function updateUser($invoice, $delivery)
|
||||
{
|
||||
try {
|
||||
$this->updateAddresses($invoice, $delivery);
|
||||
} catch (ValidationException $e) {
|
||||
$this->addErrorMessage($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->error) {
|
||||
$this->addError();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$oldUserEmail = \User::getCurrentUser()->email;
|
||||
if ($oldUserEmail != $invoice['email']) {
|
||||
$this->user->id = null;
|
||||
$this->error = $this->user->sanitizeRegistration();
|
||||
if ($this->error == 15) { // login_exists
|
||||
$this->error = 20; // login_exists_edit
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->error) {
|
||||
$id = $this->user->update();
|
||||
|
||||
// id of registered user
|
||||
return $id;
|
||||
} else {
|
||||
$this->addError();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected function registerUser($invoice, $delivery, $password)
|
||||
{
|
||||
if (Contexts::get(UserContext::class)->isActive()) {
|
||||
return Contexts::get(UserContext::class)->getActiveId();
|
||||
}
|
||||
|
||||
try {
|
||||
$this->updateAddresses($invoice, $delivery);
|
||||
} catch (ValidationException $e) {
|
||||
$this->addErrorMessage($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->error) {
|
||||
$this->addError();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->error = $this->prepareRegister($password);
|
||||
|
||||
if (!$this->error) {
|
||||
$id = $this->user->update();
|
||||
$this->user->updatePassword($this->register);
|
||||
|
||||
// id of registered user
|
||||
return $id;
|
||||
} else {
|
||||
$this->addError();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected function addError()
|
||||
{
|
||||
switch ($this->error) {
|
||||
case 1:
|
||||
addUserMessage(translate('error', 'user')['not_all_valid']);
|
||||
break;
|
||||
case 2:
|
||||
addUserMessage(replacePlaceholders(
|
||||
translate('error', 'user')['login_exists'],
|
||||
['URL' => path('kupshop_user_login_login')]
|
||||
));
|
||||
break;
|
||||
case 3:
|
||||
addUserMessage(translate('error', 'user')['false_length_passw']);
|
||||
break;
|
||||
case 4:
|
||||
addUserMessage(translate('error', 'user')['failed']);
|
||||
break;
|
||||
case 5:
|
||||
addUserMessage(translate('error', 'user')['saved']);
|
||||
break;
|
||||
case 6:
|
||||
addUserMessage(translate('error', 'user')['missing_name_invoice']);
|
||||
break;
|
||||
case 7:
|
||||
addUserMessage(translate('error', 'user')['missing_street_invoice']);
|
||||
break;
|
||||
case 8:
|
||||
addUserMessage(translate('error', 'user')['missing_city_invoice']);
|
||||
break;
|
||||
case 9:
|
||||
addUserMessage(translate('error', 'user')['missing_zip_invoice']);
|
||||
break;
|
||||
case 10:
|
||||
addUserMessage(translate('error', 'user')['missing_email_invoice']);
|
||||
break;
|
||||
case 11:
|
||||
addUserMessage(translate('error', 'user')['missing_phone_invoice']);
|
||||
break;
|
||||
case 12:
|
||||
addUserMessage(translate('error', 'user')['false_email']);
|
||||
break;
|
||||
case 13:
|
||||
addUserMessage(translate('error', 'user')['false_zip']);
|
||||
break;
|
||||
case 14:
|
||||
addUserMessage(translate('error', 'user')['false_phone']);
|
||||
break;
|
||||
case 15:
|
||||
addUserMessage(replacePlaceholders(
|
||||
translate('error', 'user')['login_exists'],
|
||||
['URL' => path('kupshop_user_login_login')]
|
||||
));
|
||||
break;
|
||||
case 16:
|
||||
addUserMessage(translate('error', 'user')['false_length_passw']);
|
||||
break;
|
||||
case 20:
|
||||
addUserMessage(translate('error', 'user')['login_exists_edit']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected function prepareRegister($password)
|
||||
{
|
||||
$this->register = false;
|
||||
|
||||
$error = $this->user->sanitizeRegistration($password);
|
||||
if (!$error) {
|
||||
$this->register = $password;
|
||||
}
|
||||
|
||||
return $error;
|
||||
}
|
||||
|
||||
protected function isNewsletterConfirmed(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function newUser()
|
||||
{
|
||||
if ($this->getType() == 'new') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function setType($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
public function setUserId($userId): self
|
||||
{
|
||||
$this->user->id = $userId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function checkCaptcha(): bool
|
||||
{
|
||||
// Check CAPTCHA
|
||||
if (findModule('recaptcha', 'registration')) {
|
||||
try {
|
||||
Captcha::checkCaptcha();
|
||||
} catch (ValidationException $e) {
|
||||
$this->addErrorMessage($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function fetchUserData($data, $user)
|
||||
{
|
||||
$data['password'] = '';
|
||||
$data['name'] = $user['name'];
|
||||
$data['surname'] = $user['surname'];
|
||||
$data['firm'] = $user['firm'];
|
||||
$data['street'] = $user['street'];
|
||||
$data['city'] = $user['city'];
|
||||
$data['zip'] = $user['zip'];
|
||||
$data['country'] = $user['country'];
|
||||
$data['state'] = $user['state'];
|
||||
$data['custom_address'] = $user['custom_address'];
|
||||
// ------------------------------
|
||||
$data['dname'] = $user['delivery_name'];
|
||||
$data['dsurname'] = $user['delivery_surname'];
|
||||
$data['dfirm'] = $user['delivery_firm'];
|
||||
$data['dstreet'] = $user['delivery_street'];
|
||||
$data['dcity'] = $user['delivery_city'];
|
||||
$data['dzip'] = $user['delivery_zip'];
|
||||
$data['dcountry'] = $user['delivery_country'];
|
||||
$data['dstate'] = $user['delivery_state'];
|
||||
$data['dcustom_address'] = $user['delivery_custom_address'];
|
||||
$data['dphone'] = $user['delivery_phone'];
|
||||
$data['demail'] = $user['delivery_email'];
|
||||
// ------------------------------
|
||||
$data['email'] = $user['email'];
|
||||
$data['ico'] = $user['ico'];
|
||||
$data['dic'] = $user['dic'];
|
||||
$data['copy_email'] = $user['copy_email'];
|
||||
$data['phone'] = $user['phone'];
|
||||
$data['mobile'] = $user['mobile'];
|
||||
$data['fax'] = $user['fax'];
|
||||
$data['gender'] = $user['gender'];
|
||||
$data['birthdate'] = $user['birthdate'];
|
||||
$data['accountNo'] = $user['account_no'];
|
||||
$data['accountBank'] = $user['account_bank'];
|
||||
$data['accountSymbol'] = $user['account_symbol'];
|
||||
$data['news'] = $user['get_news'];
|
||||
$data['transport'] = $user['prefer_transport'];
|
||||
$data['date_subscribe'] = $user['date_subscribe'];
|
||||
$data['date_unsubscribe'] = $user['date_unsubscribe'];
|
||||
|
||||
$data['custom_data'] = json_decode($user['custom_data'], true);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function updateAddresses($invoice, $delivery): void
|
||||
{
|
||||
$this->error = $this->user->updateAddresses($invoice, $delivery);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user