Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACCOUNT-2522] feat: bakend login compat v9 #431

Open
wants to merge 142 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 82 commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
575c596
feat: new vendor dependency to scope (psr)
hschoenenberger Jul 8, 2024
8306689
feat: new vendor dependency to scope (symfony)
hschoenenberger Jul 9, 2024
eeef5ce
fix: typos in psr4 namespaces
hschoenenberger Jul 9, 2024
964f7f1
fix: typos in psr4 namespaces
hschoenenberger Jul 9, 2024
7599212
fix: missing scoping dependencies
hschoenenberger Jul 9, 2024
837f29d
fix: phpstan
hschoenenberger Jul 9, 2024
9330b97
Merge remote-tracking branch 'origin/main' into ACCOUNT-2545/feat/psr…
hschoenenberger Jul 10, 2024
1623114
fix: safety check
hschoenenberger Jul 10, 2024
73a3ec7
fix: safety check
hschoenenberger Jul 10, 2024
c79f521
fix: php-cs-fixer
hschoenenberger Jul 10, 2024
5c4a935
fix: php-cs-fixer
hschoenenberger Jul 10, 2024
e963954
Merge remote-tracking branch 'origin/main' into ACCOUNT-2545/feat/psr…
hschoenenberger Jul 23, 2024
7f8744f
fix: removed target
hschoenenberger Jul 23, 2024
4210933
fix: typehint
hschoenenberger Jul 23, 2024
f4d09a2
feat: scoping ramsey/uuid
hschoenenberger Jul 23, 2024
ee0341b
feat: scoping paragonie/random_compat
hschoenenberger Jul 23, 2024
aa9dfef
feat: scoping ralouphie, phpseclib
hschoenenberger Jul 23, 2024
73b7c5a
feat: scoping paragonie/random_compat
hschoenenberger Jul 23, 2024
ee7603f
feat: catch middleware exceptions
hschoenenberger Jul 24, 2024
08c72f7
fix: getSession for ps9
hschoenenberger Jul 25, 2024
59ca47d
feat: compat trait
hschoenenberger Jul 25, 2024
7cd9eea
refactor: move trait
hschoenenberger Jul 25, 2024
0746edf
fix: more logs
hschoenenberger Jul 25, 2024
8e6ff60
refactor: preserve previous parameter
hschoenenberger Jul 25, 2024
6850c99
fix: use setter instead of overriding method
hschoenenberger Jul 25, 2024
9067cb7
feat: add a logger member
hschoenenberger Jul 25, 2024
5d858a1
fix: comment code
hschoenenberger Jul 25, 2024
c35223e
refactor: login & repository exception management
hschoenenberger Jul 25, 2024
57d1d41
Merge remote-tracking branch 'origin/main' into ACCOUNT-2545/feat/psr…
hschoenenberger Aug 5, 2024
3a4bc36
fix: php-cs-fixer
hschoenenberger Jul 9, 2024
f16e716
fix: compat & phpstan
hschoenenberger Aug 5, 2024
1a394d6
fix: adjust scoping
hschoenenberger Aug 5, 2024
53eda88
fix: bump version number
hschoenenberger Aug 7, 2024
b2d21e9
feat: first steps to migrate bo login page to symfony & more separati…
hschoenenberger Aug 14, 2024
4317864
feat: first steps to migrate bo login page to symfony & more separati…
hschoenenberger Aug 14, 2024
08acb36
fix: rename local container config path
hschoenenberger Sep 9, 2024
fc6cd33
refactor: migrate only oauth2 controller
hschoenenberger Sep 10, 2024
b8f9589
refactor: migrate only oauth2 controller
hschoenenberger Sep 10, 2024
27bff0b
refactor: migrate only oauth2 controller
hschoenenberger Sep 11, 2024
1c86f2f
refactor: migrate only oauth2 controller
hschoenenberger Sep 12, 2024
a1fdcd6
chore: remove confusing commented lines
hschoenenberger Sep 12, 2024
3dfa6eb
Merge remote-tracking branch 'origin/main' into feat/login-bo-symfony
hschoenenberger Sep 18, 2024
834454e
feat: preserve legacy controllers
hschoenenberger Sep 19, 2024
1c90aa6
feat: functional wip for sf login page
hschoenenberger Sep 20, 2024
0e94abb
feat: functional wip for sf login page
hschoenenberger Sep 20, 2024
5927730
feat: add a dedicated assets client and remove file_get_contents base…
hschoenenberger Sep 23, 2024
ff672ca
feat: logout with oauth
hschoenenberger Sep 23, 2024
9f1c731
refactor: simplify logout middleware
hschoenenberger Sep 23, 2024
a5ac8f7
refactor: simplify logout middleware
hschoenenberger Sep 24, 2024
8cf52ed
fix: redirect after login
hschoenenberger Sep 24, 2024
37cf12f
fix: employee accounts support
hschoenenberger Sep 24, 2024
d6050f1
fix: employee accounts support
hschoenenberger Sep 24, 2024
a991ec0
fix: cs-fixer & cleanup
hschoenenberger Sep 25, 2024
0a92c4d
fix: cs-fixer & cleanup
hschoenenberger Sep 25, 2024
be5ae53
fix: phpstan
hschoenenberger Sep 27, 2024
e15bebd
fix: php-cs-fixer
hschoenenberger Oct 1, 2024
4b10233
fix: phpstan for 1.7
hschoenenberger Oct 1, 2024
131fe01
fix: php-cs-fixer
hschoenenberger Oct 1, 2024
c93ce7a
fix: permissions
hschoenenberger Oct 2, 2024
ddcdcd5
refactor: test user
hschoenenberger Oct 3, 2024
c996c35
Merge remote-tracking branch 'origin/main' into feat/login-bo-symfony
hschoenenberger Oct 23, 2024
4cd5879
feat: bump version number
hschoenenberger Oct 23, 2024
ac83bb9
Merge remote-tracking branch 'origin/main' into feat/login-bo-symfony
hschoenenberger Oct 23, 2024
73795a1
feat: rely on healthcheck
hschoenenberger Oct 24, 2024
75a2db5
feat: compat
hschoenenberger Oct 24, 2024
0514f73
feat: header stamps
hschoenenberger Oct 24, 2024
e6fc087
Merge remote-tracking branch 'origin/main' into feat/login-bo-symfony
hschoenenberger Oct 25, 2024
2bb6f6f
fix: testimonial uri private to external assets client
hschoenenberger Oct 25, 2024
cbdc6b0
fix: move up some code
hschoenenberger Oct 25, 2024
db3f753
fix: no implicit dependencies
hschoenenberger Oct 25, 2024
dc39dab
fix: no implicit dependencies
hschoenenberger Oct 25, 2024
984046b
fix: typo
hschoenenberger Oct 25, 2024
5f74233
fix: oauth2 redirect uris for v9
hschoenenberger Oct 30, 2024
79acd3f
fix: phpdoc typehints
hschoenenberger Oct 30, 2024
5fbca2c
fix: reduce duplication
hschoenenberger Oct 30, 2024
ae8463a
refactor: service container directory
hschoenenberger Oct 31, 2024
eb97a0a
fix: argument check
hschoenenberger Oct 31, 2024
46c35f9
Merge remote-tracking branch 'origin/main' into feat/login-bo-symfony
hschoenenberger Oct 31, 2024
0e4cc83
fix: i18n
hschoenenberger Oct 31, 2024
e0cc684
fix: i18n
hschoenenberger Oct 31, 2024
58c6a0b
fix: i18n
hschoenenberger Oct 31, 2024
d3ef597
missing parameter
hschoenenberger Nov 4, 2024
b61fed1
refactor: get rid of module-lib-service-container
hschoenenberger Nov 4, 2024
4107e05
refactor: remove useless deps
hschoenenberger Nov 4, 2024
708004b
fix: phpstan, php-cs-fixer & feature tests
hschoenenberger Nov 5, 2024
8a6c7e0
fix: phpstan, php-cs-fixer & feature tests
hschoenenberger Nov 5, 2024
fcc505c
fix: phpstan, php-cs-fixer & feature tests
hschoenenberger Nov 5, 2024
f2ad306
fix: phpstan, php-cs-fixer & feature tests
hschoenenberger Nov 5, 2024
4dee0ae
fix: php-cs-fixer
hschoenenberger Nov 5, 2024
a894c77
fix: cleanup
hschoenenberger Nov 5, 2024
1290d3b
refactor: create provider files
hschoenenberger Nov 5, 2024
2396550
refactor: create provider files
hschoenenberger Nov 5, 2024
3bc7f20
chore: empty services files
hschoenenberger Nov 5, 2024
7169c3f
chore: empty services files
hschoenenberger Nov 5, 2024
33259be
chore: empty services files
hschoenenberger Nov 5, 2024
0454058
chore: empty services files
hschoenenberger Nov 6, 2024
65d73df
fix: cherry pick some fixes
hschoenenberger Nov 8, 2024
7ff4888
fix: cherry pick some fixes
hschoenenberger Nov 8, 2024
c35fdfa
chore: cleanup composer.json
hschoenenberger Nov 13, 2024
927e1ca
fix: static closures
hschoenenberger Nov 13, 2024
11dcd16
refactor: early logger injection
hschoenenberger Nov 18, 2024
d48bc95
chore: wip ci
hschoenenberger Nov 18, 2024
6e6107e
Merge remote-tracking branch 'origin/main' into feat/login-bo-symfony
hschoenenberger Nov 19, 2024
7f7161e
fix: config path config
hschoenenberger Nov 19, 2024
e83d2b1
refactor: renaming
hschoenenberger Nov 19, 2024
2163659
refactor: renaming
hschoenenberger Nov 19, 2024
7209911
Merge remote-tracking branch 'origin/main' into refactor/service-cont…
hschoenenberger Nov 19, 2024
f2ddb33
fix: monolog namespace
hschoenenberger Nov 19, 2024
3c87bba
fix: monolog namespace
hschoenenberger Nov 19, 2024
d80ee7c
chore: inactivate unused patcher
hschoenenberger Nov 19, 2024
657e250
chore: remove unused namespace
hschoenenberger Nov 19, 2024
73d8ea5
fix: phpstan 2.0
hschoenenberger Nov 20, 2024
6ce1bbf
fix: ci bundle zip with config.php
hschoenenberger Nov 20, 2024
81e4b0e
fix: ci bundle zip with config.php
hschoenenberger Nov 20, 2024
2eb5202
fix: cleanup obsolete steps
hschoenenberger Nov 20, 2024
6074095
feat: ci php 8.1
hschoenenberger Nov 20, 2024
ce58597
feat: ci php 8
hschoenenberger Nov 20, 2024
407d7c2
feat: syntax checker
hschoenenberger Nov 20, 2024
aa03f8c
feat: syntax checker
hschoenenberger Nov 20, 2024
54cbc4d
chore: update monolog & syntax check on scoped vendor
hschoenenberger Nov 21, 2024
aae7f09
chore: update monolog & syntax check on scoped vendor
hschoenenberger Nov 21, 2024
6b11fe7
refactor: switch to the lightweight-container lib
hschoenenberger Nov 26, 2024
3f0252b
chore: php-cs-fixer
hschoenenberger Nov 26, 2024
2ba8f00
feat: scoping lightweight-container
hschoenenberger Nov 26, 2024
6208fb4
feat: scoping lightweight-container
hschoenenberger Nov 26, 2024
35cdd37
Merge remote-tracking branch 'origin/main' into refactor/service-cont…
hschoenenberger Nov 26, 2024
92faa3c
fix: post merge
hschoenenberger Nov 26, 2024
c2313f8
fix: phpstan
hschoenenberger Nov 26, 2024
e1d5abf
fix: builder method return type bound to the concrete class
hschoenenberger Nov 26, 2024
2ac34b3
chore: cleanup unused scripts
hschoenenberger Nov 26, 2024
a9be934
fix: licence linkl
hschoenenberger Nov 26, 2024
1a04d1e
Merge branch 'refactor/service-container' into feat/login-bo-symfony
hschoenenberger Nov 27, 2024
85aec86
fix: renaming distinct member
hschoenenberger Nov 27, 2024
0a77fea
Merge branch 'refactor/service-container' into feat/login-bo-symfony
hschoenenberger Nov 27, 2024
983f491
fix: header-stamp
hschoenenberger Nov 27, 2024
99ad669
fix: missing service
hschoenenberger Nov 27, 2024
71f6691
fix: return type
hschoenenberger Nov 27, 2024
d66d50a
fix: bump lightweight-container
hschoenenberger Nov 27, 2024
659d461
fix: unused use
hschoenenberger Nov 27, 2024
76334dc
Merge remote-tracking branch 'origin/main' into feat/login-bo-symfony
hschoenenberger Nov 29, 2024
49bf2a6
fix: lazy module instantiation
hschoenenberger Nov 29, 2024
7dabec8
Merge remote-tracking branch 'origin/main' into feat/login-bo-symfony
hschoenenberger Dec 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .docker/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ services:
prestashop:
container_name: phpunit
# image: 'prestashop/prestashop-flashlight:1.7.6.9-7.2'
# image: prestashop/prestashop-flashlight:8.1.5-7.4
image: ${PLATFORM_IMAGE}
healthcheck:
test: curl --fail http://localhost:80 || exit 1
interval: 10s
timeout: 10s
retries: 5
# user: www-data
user: root
environment:
- PS_DOMAIN=localhost
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ views/files/*
npm-debug.log*
yarn-debug.log*
yarn-error.log*

/cache/
2 changes: 2 additions & 0 deletions .zip-contents
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
config
config_module
controllers
sql
src
templates
translations
upgrade
vendor
Expand Down
3 changes: 2 additions & 1 deletion .zip-excludes
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
*.docker/*
*.idea/*
*tests/*
*config/config.yml.*
*config/config.yml*
*config_module/config.yml.*
*.bak/*
*.md/*
*composer.*
Expand Down
19 changes: 11 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ platform-restart: platform-stop platform-start

platform-module-config:
@docker exec -w ${CONTAINER_INSTALL_DIR} phpunit \
sh -c "if [ ! -f ./config/config.yml ]; then cp ./config/config.yml.dist ./config/config.yml; fi"
sh -c "if [ ! -f ./config_module/config.yml ]; then cp ./config_module/config.yml.dist ./config_module/config.yml; fi"

platform-module-version:
@docker exec -w ${CONTAINER_INSTALL_DIR} phpunit \
Expand All @@ -75,9 +75,12 @@ platform-module-install: tests/vendor platform-phpstan-config platform-module-co
-@docker exec phpunit sh -c "if [ ! -f ./bin/console ]; then php -d memory_limit=-1 ./modules/ps_accounts/tests/install-module.php; fi"

platform-fix-permissions:
@docker exec phpunit sh -c "if [ -d ./var ]; then chown -R www-data:www-data ./var; fi"
@docker exec phpunit sh -c "if [ -d ./cache ]; then chown -R www-data:www-data ./cache; fi" # PS1.6
@docker exec phpunit sh -c "if [ -d ./log ]; then chown -R www-data:www-data ./log; fi" # PS1.6
@docker exec -u root phpunit sh -c "if [ -d ./var ]; then chown -R www-data:www-data ./var; fi"
@docker exec -u root phpunit sh -c "if [ -d ./cache ]; then chown -R www-data:www-data ./cache; fi" # PS1.6
@docker exec -u root phpunit sh -c "if [ -d ./log ]; then chown -R www-data:www-data ./log; fi" # PS1.6
@docker exec -u root phpunit sh -c "chgrp -R www-data ${CONTAINER_INSTALL_DIR}"
@docker exec -u root phpunit sh -c "find ${CONTAINER_INSTALL_DIR} -type d -exec chmod g+r,g+w,g+x {} \;"
@docker exec -u root phpunit sh -c "find ${CONTAINER_INSTALL_DIR} -type f -exec chmod g+r,g+w {} \;"

#phpunit-xdebug:
# -@docker exec phpunit sh -c "docker-php-ext-enable xdebug"
Expand Down Expand Up @@ -255,13 +258,13 @@ BUNDLE_ZIP ?= # ex: ps_accounts_flavor.zip
BUNDLE_VERSION ?= $(shell grep "<version>" config.xml | sed 's/^.*\([0-9]\+\.[0-9]\+\.[0-9]\+\).*/\1/')
BUNDLE_JS ?= views/js/app.${BUNDLE_VERSION}.js

bundle: php-scoper config/config.yml build-front
bundle: php-scoper config_module/config.yml build-front
@./scripts/bundle-module.sh "${BUNDLE_ZIP}" "${BUNDLE_ENV}"

bundle-prod: php-scoper config/config.yml.prod build-front
bundle-prod: php-scoper config_module/config.yml.prod build-front
@./scripts/bundle-module.sh "ps_accounts.zip" "prod"

bundle-preprod: php-scoper config/config.yml.preprod build-front
bundle-preprod: php-scoper config_module/config.yml.preprod build-front
@./scripts/bundle-module.sh "ps_accounts_preprod.zip" "preprod"

define build_front
Expand Down Expand Up @@ -296,7 +299,7 @@ autoindex: tests/vendor

header-stamp: COMPOSER_FILE := composer56.json
header-stamp: tests/vendor
${PHP} ./vendor/bin/header-stamp --target="${WORKDIR}" --license="assets/afl.txt" --exclude=".github,node_modules,vendor,vendor,tests,_dev"
${PHP} ./tests/vendor/bin/header-stamp --target="${WORKDIR}" --license="assets/afl.txt" --exclude=".github,node_modules,vendor,vendor,tests,_dev"

##########################################################
COMPOSER_OPTIONS ?= --prefer-dist -o --no-dev --quiet
Expand Down
2 changes: 1 addition & 1 deletion _dev/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ps_accounts",
"version": "7.0.8",
"version": "7.0.9",
"private": true,
"scripts": {
"dev": "vite",
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@
]
},
"author": "PrestaShop"
}
}
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<module>
<name>ps_accounts</name>
<displayName><![CDATA[PrestaShop Account]]></displayName>
<version><![CDATA[7.0.8]]></version>
<version><![CDATA[7.0.9]]></version>
<description><![CDATA[Link your store to your PrestaShop account to activate and manage your subscriptions in your back office. Do not uninstall this module if you have a current subscription.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[administration]]></tab>
Expand Down
2 changes: 1 addition & 1 deletion config/admin/services.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
imports:
- { resource: ../config.yml }
- { resource: ../services.yml }
2 changes: 1 addition & 1 deletion config/front/services.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
imports:
- { resource: ../config.yml }
- { resource: ../services.yml }
48 changes: 48 additions & 0 deletions config/routes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
ps_accounts_oauth2:
path: ps_accounts/oauth2
methods: [GET]
defaults:
_controller: 'PrestaShop\Module\PsAccounts\Controller\Admin\OAuth2Controller::initOAuth2FlowAction'
_anonymous_controller: true
_legacy_controller: SfAdminOAuth2PsAccounts
_legacy_link: SfAdminOAuth2PsAccounts

## override login (+ forward original login)
#ps_accounts_login:
# path: /login
# methods: [GET]
# defaults:
# _controller: 'PrestaShop\Module\PsAccounts\Controller\Admin\OAuth2Controller::displayLogin'
# _anonymous_controller: true
# _legacy_controller: SfAdminLoginPsAccounts
# _legacy_link: SfAdminLoginPsAccounts
# _disable_module_prefix: true
#
#ps_accounts_local_login:
# path: /local-login
# methods: [GET]
# defaults:
# _controller: 'PrestaShop\Module\PsAccounts\Controller\Admin\OAuth2Controller::displayLocalLogin'
# _anonymous_controller: true
# _legacy_controller: SfAdminLocalLoginPsAccounts
# _legacy_link: SfAdminLocalLoginPsAccounts
# _disable_module_prefix: true

ps_accounts_login:
path: ps_accounts/login
methods: [GET]
defaults:
_controller: 'PrestaShop\Module\PsAccounts\Controller\Admin\OAuth2Controller::displayLoginAction'
_anonymous_controller: true
_legacy_controller: SfAdminLoginPsAccounts
_legacy_link: SfAdminLoginPsAccounts

# TODO: Or we preserve original legacy controller or we create a legacy sf route
#ps_accounts_oauth2_legacy:
# path: ps_accounts/oauth2_legacy
# methods: [GET]
# defaults:
# _controller: 'PrestaShop\Module\PsAccounts\Controller\Admin\OAuth2Controller::initOAuth2FlowLegacy'
# _anonymous_controller: true
# _legacy_controller: AdminOAuth2PsAccounts
# _legacy_link: AdminOAuth2PsAccounts
11 changes: 11 additions & 0 deletions config/services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
services:
PrestaShop\Module\PsAccounts\Controller\Admin\OAuth2Controller:
class: PrestaShop\Module\PsAccounts\Controller\Admin\OAuth2Controller
# autowire: true
# autoconfigure: true

PrestaShop\Module\PsAccounts\EventListener\Admin\LogoutSubscriber:
class: PrestaShop\Module\PsAccounts\EventListener\Admin\LogoutSubscriber
tags:
- name: kernel.event_subscriber
dispatcher: security.event_dispatcher.main
2 changes: 2 additions & 0 deletions config_module/admin/services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
imports:
- { resource: ../config.yml }
File renamed without changes.
7 changes: 7 additions & 0 deletions config/common.yml → config_module/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ services:
- null
- 10

PrestaShop\Module\PsAccounts\Api\Client\ExternalAssetsClient:
class: PrestaShop\Module\PsAccounts\Api\Client\ExternalAssetsClient
public: true
arguments:
- null
- 10

PrestaShop\Module\PsAccounts\Api\Client\ServicesBillingClient:
class: PrestaShop\Module\PsAccounts\Api\Client\ServicesBillingClient
public: true
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions config_module/front/services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
imports:
- { resource: ../config.yml }
54 changes: 24 additions & 30 deletions controllers/admin/AdminLoginPsAccountsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/

use PrestaShop\Module\PsAccounts\Api\Client\ExternalAssetsClient;
use PrestaShop\Module\PsAccounts\Polyfill\Traits\AdminController\IsAnonymousAllowed;
use PrestaShop\Module\PsAccounts\Provider\OAuth2\ShopProvider;

Expand All @@ -27,11 +28,20 @@ class AdminLoginPsAccountsController extends \AdminController

const PARAM_MODE_LOCAL = 'local';

/** @var string */
/**
* @var string
*/
public $template = 'login.tpl';

/** @var Ps_accounts */
private $psAccounts;
/**
* @var Ps_accounts
*/
public $module;

/**
* @var ExternalAssetsClient
*/
private $externalAssetsClient;

/**
* @throws Exception
Expand All @@ -50,8 +60,9 @@ public function __construct()

/** @var Ps_accounts $module */
$module = Module::getInstanceByName('ps_accounts');
$this->module = $module;

$this->psAccounts = $module;
$this->externalAssetsClient = $this->module->getService(ExternalAssetsClient::class);

if (!headers_sent()) {
header('Login: true');
Expand Down Expand Up @@ -108,8 +119,8 @@ public function viewAccess($disable = false)
*/
public function setMedia($isNewTheme = false)
{
$this->addCss($this->psAccounts->getLocalPath() . '/views/css/login.css');
$this->addJS($this->psAccounts->getLocalPath() . '/views/js/login.js');
$this->addCss($this->module->getLocalPath() . '/views/css/login.css');
$this->addJS($this->module->getLocalPath() . '/views/js/login.js');
}

/**
Expand All @@ -122,11 +133,11 @@ public function setMedia($isNewTheme = false)
public function createTemplate($tpl_name)
{
/** @var ShopProvider $provider */
$provider = $this->psAccounts->getService(ShopProvider::class);
$provider = $this->module->getService(ShopProvider::class);

$testimonials = $this->getTestimonials();

$session = $this->psAccounts->getSession();
$session = $this->module->getSession();

/* @phpstan-ignore-next-line */
$isoCode = $this->context->currentLocale->getCode();
Expand All @@ -144,42 +155,25 @@ public function createTemplate($tpl_name)
'testimonials' => $testimonials,
'loginError' => $session->remove('loginError'),
'meta_title' => '',
'ssoResendVerificationEmail' => $this->psAccounts->getParameter(
'ssoResendVerificationEmail' => $this->module->getParameter(
'ps_accounts.sso_resend_verification_email_url'
),
]);

/* @phpstan-ignore-next-line */
return $this->context->smarty->createTemplate(
$this->psAccounts->getLocalPath() . '/views/templates/admin/' . $this->template,
$this->module->getLocalPath() . '/views/templates/admin/' . $this->template,
$this->context->smarty
);
}

/**
* @return array
*
* @throws Exception
*/
private function getTestimonials()
{
$verify = (bool) $this->psAccounts->getParameter('ps_accounts.check_api_ssl_cert');

return json_decode(
(string) Tools::file_get_contents(
$this->psAccounts->getParameter('ps_accounts.testimonials_url'),
false,
stream_context_create([
'ssl' => [
'verify_peer' => $verify,
'verify_peer_name' => $verify,
],
'http' => [
'ignore_errors' => '1',
],
])
),
true
) ?: [];
$res = $this->externalAssetsClient->getTestimonials();

return $res['status'] ? $res['body'] : [];
}
}
Loading
Loading