first commit
This commit is contained in:
65
modules/ps_accounts/.docker/install_module.sh
Normal file
65
modules/ps_accounts/.docker/install_module.sh
Normal file
@@ -0,0 +1,65 @@
|
||||
#!/bin/sh
|
||||
|
||||
LIB_PATH=/tmp/libs/php/prestashop_accounts_auth/
|
||||
|
||||
# git branch to be referenced into composer-dev.json
|
||||
parse_git_branch() {
|
||||
cd $LIB_PATH;
|
||||
if [ `which git` ]; then
|
||||
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' -e 's/\//\\\//';
|
||||
else
|
||||
echo 'master'
|
||||
fi
|
||||
}
|
||||
|
||||
groupmod -g $UID www-data
|
||||
usermod -u $UID -g $GID www-data
|
||||
|
||||
wget -qO- https://deb.nodesource.com/setup_12.x | bash -
|
||||
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
||||
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
|
||||
|
||||
apt update \
|
||||
&& apt install -y vim nano wget nodejs yarn \
|
||||
&& php -r "readfile('https://getcomposer.org/installer');" | php -- --install-dir=/usr/local/bin --filename=composer \
|
||||
&& chmod +x /usr/local/bin/composer \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \
|
||||
&& curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version \
|
||||
&& mkdir -p /tmp/blackfire \
|
||||
&& tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \
|
||||
&& mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so \
|
||||
&& printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > $PHP_INI_DIR/conf.d/blackfire.ini \
|
||||
&& rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz
|
||||
|
||||
for module in ps_accounts ps_checkout ps_metrics
|
||||
do
|
||||
cd /var/www/html/modules/$module;
|
||||
rm -f composer-dev.json composer-dev.lock;
|
||||
cp composer.json composer-dev.json;
|
||||
sed -i "/^}/i \\
|
||||
,\"repositories\": [\\
|
||||
{\\
|
||||
\"type\": \"path\",\\
|
||||
\"url\": \"`echo $LIB_PATH | sed -e 's/\//\\//'`\"\\
|
||||
}\\
|
||||
]" composer-dev.json;
|
||||
sed -i "s/\(\"prestashop\/prestashop-accounts-auth\"\): \"[^\"]*\"/\1: \"dev-$(parse_git_branch)\"/g" \
|
||||
composer-dev.json;
|
||||
composer install;
|
||||
/var/www/html/bin/console --env=prod prestashop:module install $module
|
||||
done
|
||||
|
||||
yarn --cwd /tmp/libs/js/prestashop_accounts_vue_components/
|
||||
yarn --cwd /tmp/libs/js/prestashop_accounts_vue_components/ build-lib
|
||||
yarn --cwd /var/www/html/modules/ps_checkout/_dev/
|
||||
yarn --cwd /var/www/html/modules/ps_checkout/_dev/ build
|
||||
yarn --cwd /var/www/html/modules/ps_metrics/_dev/
|
||||
yarn --cwd /var/www/html/modules/ps_metrics/_dev/ build
|
||||
|
||||
rm -rf /var/www/html/modules/ps_checkout/_dev/node_modules/prestashop_accounts_vue_components
|
||||
ln -s /tmp/libs/js/prestashop_accounts_vue_components /var/www/html/modules/ps_checkout/_dev/node_modules/prestashop_accounts_vue_components
|
||||
|
||||
rm -rf /var/www/html/var/cache/*;
|
||||
|
||||
12
modules/ps_accounts/.docker/patches/ignore-checkout-17.diff
Normal file
12
modules/ps_accounts/.docker/patches/ignore-checkout-17.diff
Normal file
@@ -0,0 +1,12 @@
|
||||
diff --git src/PrestaShopBundle/Install/Install.php src/PrestaShopBundle/Install/Install.php
|
||||
index 333909180d..fb896d6624 100644
|
||||
--- src/PrestaShopBundle/Install/Install.php
|
||||
+++ src/PrestaShopBundle/Install/Install.php
|
||||
@@ -974,6 +974,7 @@ class Install extends AbstractInstall
|
||||
'producttooltip',
|
||||
'sendtoafriend',
|
||||
'socialsharing',
|
||||
+ 'ps_checkout',
|
||||
);
|
||||
|
||||
$addons_modules = array();
|
||||
5
modules/ps_accounts/.docker/prepare.sh
Normal file
5
modules/ps_accounts/.docker/prepare.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Apply patches"
|
||||
cd /var/www/html
|
||||
patch -p0 -f < /tmp/patches/ignore-checkout-17.diff || true
|
||||
171
modules/ps_accounts/LICENSE
Normal file
171
modules/ps_accounts/LICENSE
Normal file
@@ -0,0 +1,171 @@
|
||||
Academic Free License (“AFL”) v. 3.0
|
||||
|
||||
This Academic Free License (the "License") applies to any original work of
|
||||
authorship (the "Original Work") whose owner (the "Licensor") has placed the
|
||||
following licensing notice adjacent to the copyright notice for the Original
|
||||
Work:
|
||||
|
||||
Licensed under the Academic Free License version 3.0
|
||||
|
||||
1) Grant of Copyright License. Licensor grants You a worldwide, royalty-free,
|
||||
non-exclusive, sublicensable license, for the duration of the copyright, to do
|
||||
the following:
|
||||
|
||||
a) to reproduce the Original Work in copies, either alone or as part of a
|
||||
collective work;
|
||||
|
||||
b) to translate, adapt, alter, transform, modify, or arrange the Original
|
||||
Work, thereby creating derivative works ("Derivative Works") based upon
|
||||
the Original Work;
|
||||
|
||||
c) to distribute or communicate copies of the Original Work and
|
||||
Derivative Works to the public, under any license of your choice that
|
||||
does not contradict the terms and conditions, including Licensor’s
|
||||
reserved rights and remedies, in this Academic Free License;
|
||||
d) to perform the Original Work publicly; and
|
||||
e) to display the Original Work publicly.
|
||||
|
||||
2) Grant of Patent License. Licensor grants You a worldwide, royalty-free,
|
||||
non-exclusive, sublicensable license, under patent claims owned or controlled
|
||||
by the Licensor that are embodied in the Original Work as furnished by the
|
||||
Licensor, for the duration of the patents, to make, use, sell, offer for sale,
|
||||
have made, and import the Original Work and Derivative Works.
|
||||
|
||||
3) Grant of Source Code License. The term "Source Code" means the preferred
|
||||
form of the Original Work for making modifications to it and all available
|
||||
documentation describing how to modify the Original Work. Licensor agrees to
|
||||
provide a machine-readable copy of the Source Code of the Original Work along
|
||||
with each copy of the Original Work that Licensor distributes. Licensor
|
||||
reserves the right to satisfy this obligation by placing a machine-readable
|
||||
copy of the Source Code in an information repository reasonably calculated to
|
||||
permit inexpensive and convenient access by You for as long as Licensor
|
||||
continues to distribute the Original Work.
|
||||
|
||||
4) Exclusions From License Grant. Neither the names of Licensor, nor the names
|
||||
of any contributors to the Original Work, nor any of their trademarks or
|
||||
service marks, may be used to endorse or promote products derived from this
|
||||
Original Work without express prior permission of the Licensor. Except as
|
||||
expressly stated herein, nothing in this License grants any license to
|
||||
Licensor’s trademarks, copyrights, patents, trade secrets or any other
|
||||
intellectual property. No patent license is granted to make, use, sell, offer
|
||||
for sale, have made, or import embodiments of any patent claims other than the
|
||||
licensed claims defined in Section 2. No license is granted to the trademarks
|
||||
of Licensor even if such marks are included in the Original Work. Nothing in
|
||||
this License shall be interpreted to prohibit Licensor from licensing under
|
||||
terms different from this License any Original Work that Licensor otherwise
|
||||
would have a right to license.
|
||||
|
||||
5) External Deployment. The term "External Deployment" means the use,
|
||||
distribution, or communication of the Original Work or Derivative Works in any
|
||||
way such that the Original Work or Derivative Works may be used by anyone
|
||||
other than You, whether those works are distributed or communicated to those
|
||||
persons or made available as an application intended for use over a network.
|
||||
As an express condition for the grants of license hereunder, You must treat
|
||||
any External Deployment by You of the Original Work or a Derivative Work as a
|
||||
distribution under section 1(c).
|
||||
|
||||
6) Attribution Rights. You must retain, in the Source Code of any Derivative
|
||||
Works that You create, all copyright, patent, or trademark notices from the
|
||||
Source Code of the Original Work, as well as any notices of licensing and any
|
||||
descriptive text identified therein as an "Attribution Notice." You must cause
|
||||
the Source Code for any Derivative Works that You create to carry a prominent
|
||||
Attribution Notice reasonably calculated to inform recipients that You have
|
||||
modified the Original Work.
|
||||
|
||||
7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that
|
||||
the copyright in and to the Original Work and the patent rights granted herein
|
||||
by Licensor are owned by the Licensor or are sublicensed to You under the
|
||||
terms of this License with the permission of the contributor(s) of those
|
||||
copyrights and patent rights. Except as expressly stated in the immediately
|
||||
preceding sentence, the Original Work is provided under this License on an "AS
|
||||
IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without
|
||||
limitation, the warranties of non-infringement, merchantability or fitness for
|
||||
a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK
|
||||
IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this
|
||||
License. No license to the Original Work is granted by this License except
|
||||
under this disclaimer.
|
||||
|
||||
8) Limitation of Liability. Under no circumstances and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise, shall the
|
||||
Licensor be liable to anyone for any indirect, special, incidental, or
|
||||
consequential damages of any character arising as a result of this License or
|
||||
the use of the Original Work including, without limitation, damages for loss
|
||||
of goodwill, work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses. This limitation of liability shall not
|
||||
apply to the extent applicable law prohibits such limitation.
|
||||
|
||||
9) Acceptance and Termination. If, at any time, You expressly assented to this
|
||||
License, that assent indicates your clear and irrevocable acceptance of this
|
||||
License and all of its terms and conditions. If You distribute or communicate
|
||||
copies of the Original Work or a Derivative Work, You must make a reasonable
|
||||
effort under the circumstances to obtain the express assent of recipients to
|
||||
the terms of this License. This License conditions your rights to undertake
|
||||
the activities listed in Section 1, including your right to create Derivative
|
||||
Works based upon the Original Work, and doing so without honoring these terms
|
||||
and conditions is prohibited by copyright law and international treaty.
|
||||
Nothing in this License is intended to affect copyright exceptions and
|
||||
limitations (including “fair use” or “fair dealing”). This License shall
|
||||
terminate immediately and You may no longer exercise any of the rights granted
|
||||
to You by this License upon your failure to honor the conditions in Section
|
||||
1(c).
|
||||
|
||||
10) Termination for Patent Action. This License shall terminate automatically
|
||||
and You may no longer exercise any of the rights granted to You by this
|
||||
License as of the date You commence an action, including a cross-claim or
|
||||
counterclaim, against Licensor or any licensee alleging that the Original Work
|
||||
infringes a patent. This termination provision shall not apply for an action
|
||||
alleging patent infringement by combinations of the Original Work with other
|
||||
software or hardware.
|
||||
|
||||
11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this
|
||||
License may be brought only in the courts of a jurisdiction wherein the
|
||||
Licensor resides or in which Licensor conducts its primary business, and under
|
||||
the laws of that jurisdiction excluding its conflict-of-law provisions. The
|
||||
application of the United Nations Convention on Contracts for the
|
||||
International Sale of Goods is expressly excluded. Any use of the Original
|
||||
Work outside the scope of this License or after its termination shall be
|
||||
subject to the requirements and penalties of copyright or patent law in the
|
||||
appropriate jurisdiction. This section shall survive the termination of this
|
||||
License.
|
||||
|
||||
12) Attorneys’ Fees. In any action to enforce the terms of this License or
|
||||
seeking damages relating thereto, the prevailing party shall be entitled to
|
||||
recover its costs and expenses, including, without limitation, reasonable
|
||||
attorneys' fees and costs incurred in connection with such action, including
|
||||
any appeal of such action. This section shall survive the termination of this
|
||||
License.
|
||||
|
||||
13) Miscellaneous. If any provision of this License is held to be
|
||||
unenforceable, such provision shall be reformed only to the extent necessary
|
||||
to make it enforceable.
|
||||
|
||||
14) Definition of "You" in This License. "You" throughout this License,
|
||||
whether in upper or lower case, means an individual or a legal entity
|
||||
exercising rights under, and complying with all of the terms of, this License.
|
||||
For legal entities, "You" includes any entity that controls, is controlled by,
|
||||
or is under common control with you. For purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the direction or
|
||||
management of such entity, whether by contract or otherwise, or (ii) ownership
|
||||
of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial
|
||||
ownership of such entity.
|
||||
|
||||
15) Right to Use. You may use the Original Work in all ways not otherwise
|
||||
restricted or conditioned by this License or by law, and Licensor promises not
|
||||
to interfere with or be responsible for such uses by You.
|
||||
|
||||
16) Modification of This License. This License is Copyright © 2005 Lawrence
|
||||
Rosen. Permission is granted to copy, distribute, or communicate this License
|
||||
without modification. Nothing in this License permits You to modify this
|
||||
License as applied to the Original Work or to Derivative Works. However, You
|
||||
may modify the text of this License and copy, distribute or communicate your
|
||||
modified version (the "Modified License") and apply it to other original works
|
||||
of authorship subject to the following conditions: (i) You may not indicate in
|
||||
any way that your Modified License is the "Academic Free License" or "AFL" and
|
||||
you may not use those names in the name of your Modified License; (ii) You
|
||||
must replace the notice specified in the first paragraph above with the notice
|
||||
"Licensed under <insert your license name here>" or with a notice of your own
|
||||
that is not confusingly similar to the notice in this License; and (iii) You
|
||||
may not claim that your original works are open source software unless your
|
||||
Modified License has been approved by Open Source Initiative (OSI) and You
|
||||
comply with its license review and certification process.
|
||||
|
||||
115
modules/ps_accounts/README.md
Normal file
115
modules/ps_accounts/README.md
Normal file
@@ -0,0 +1,115 @@
|
||||
# PrestaShop Account
|
||||
|
||||
## Introduction
|
||||
|
||||
The module **ps_accounts** is the interface between your module (PSx / Community Service) and PrestaShop's Accounts service.
|
||||
- It manages the shop link and unlink to a user account.
|
||||
- It can receives informations from PrestaShop's Accounts API to update data about user and/or shop authentication and verification.
|
||||
- It can be queried by AJAX calls from your module
|
||||
|
||||
Your PSx or Community Service needs to call this module in order to use PrestaShop Accounts service.
|
||||
|
||||
### Work as Community Service or PrestaShop X modules (PSx)
|
||||
|
||||
Your module needs three parts :
|
||||
|
||||
- [PS Accounts module](http://github.com/PrestaShopCorp/ps_accounts)
|
||||
- This module must be installed.
|
||||
- It's your interface between your module and PrestaShop Accounts service.
|
||||
|
||||
And in your PSx :
|
||||
|
||||
- [PS Accounts Installer (Composer Library)](http://github.com/PrestaShopCorp/prestashop-accounts-installer)
|
||||
- This library's role is here to compensate a lack of security between modules dependencies. If PS Accounts is removed while your module is still installed: it causes a crash of the PrestaShop module's page/feature.
|
||||
- This library is here to install automatically PS Accounts if it's missing.
|
||||
- It's your interface between your module and PrestaShop Accounts module
|
||||
- You should never require directly PrestaShop\Module\PsAccounts namespace classes
|
||||
|
||||
- [PrestaShop Accounts Vue Components](http://github.com/PrestaShopCorp/prestashop_accounts_vue_components)
|
||||
- It's the front-end component you need to integrate into your module's configuration page.
|
||||
- :warning: TODO:Introduce the VueJS component and redirect to its doc
|
||||
|
||||
## Installation
|
||||
|
||||
If you need to install and test the module, [you can download the desired zip here](https://github.com/PrestaShopCorp/ps_accounts/releases)
|
||||
- **ps_accounts.zip** is the "**production** ready zip"
|
||||
- **ps_accounts_integration.zip** is the zip you need if you want to test on the **integration environment**.
|
||||
|
||||
## How to start working with PS Accounts as a PSx or Community Service developer?
|
||||
|
||||
- [Read the official documentation here](https://devdocs.prestashop.com/1.7/modules/)
|
||||
- Clone this repository
|
||||
- Copy paste the `config/config.yml.dist` to `config/config.yml`
|
||||
|
||||
## Continous Integration
|
||||
|
||||
CI trigger on pull request labeled 'quality assurance needed'
|
||||
|
||||
To set custom checkout branch , edit [custom-checkout-version](custom-checkout-version)
|
||||
|
||||
## Testing
|
||||
|
||||
:warning: TODO To be verified with @hSchoenenberger
|
||||
|
||||
## JWT
|
||||
|
||||
### What are JWTs and how are they used?
|
||||
|
||||
JWT are [JSON Web Tokens](https://jwt.io/).
|
||||
|
||||
We use JWTs for 2 types of account: the user account and the shop account.
|
||||
What we're identifying when we link a PrestaShop shop is **a shop**. A shop belongs to 1 owner (user).
|
||||
|
||||
There are 2 Firebase projects:
|
||||
- **prestashop-newsso-production** is the Firebase Authentication project we're using to authenticate **users** _(prestashop-newsso-staging) for staging environment_
|
||||
- **prestashop-ready-prod** is the Firebase Authentication project we're using to authenticate **shops** _(psessentials-integration) for integration environment_
|
||||
|
||||
**Don't try to verify a shop token against **prestashop-newsso-production** it won't work.**
|
||||
|
||||
There are 3 kinds of tokens that can interest you:
|
||||
- Firebase ID Token
|
||||
- Firebase Custom Token
|
||||
- Firebase Refresh token
|
||||
|
||||
[For more informations, please read the official documentation here](https://firebase.google.com/docs/auth/users#auth_tokens)
|
||||
|
||||
Here is a recap of the configuration variables used to manage a shop account
|
||||
|
||||
| ps_configuration | User account (Firebase SSO) | Shop (Firebase Ready) | What for ?
|
||||
|---------------------------------------|-----|-------|---
|
||||
| PS_ACCOUNTS_FIREBASE_ID_TOKEN | | X | authenticate your shop, query accounts-api, billing-api...
|
||||
| PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN | | X |
|
||||
| PSX_UUID_V4 | | X | identify your shop
|
||||
| PS_ACCOUNTS_FIREBASE_EMAIL | X | | identify your account
|
||||
| PS_ACCOUNTS_FIREBASE_EMAIL_IS_VERIFIED| X | |
|
||||
|
||||
### How to refresh the JWT
|
||||
|
||||
```php
|
||||
use PrestaShop\PsAccountsInstaller\Installer\Installer;
|
||||
use PrestaShop\PsAccountsInstaller\Installer\Facade\PsAccounts;
|
||||
|
||||
define('MIN_PS_ACCOUNTS_VERSION', '4.0.0');
|
||||
|
||||
$facade = new PsAccounts(new Installer(MIN_PS_ACCOUNTS_VERSION));
|
||||
$shopToken = $facade->getPsAccountsService()->getOrRefreshToken();
|
||||
```
|
||||
|
||||
see: [PrestaShop Accounts Installer](http://github.com/PrestaShopCorp/prestashop-accounts-installer) for more details on how to setup Installer.
|
||||
|
||||
## Breaking Changes
|
||||
### Removal of the environment variables
|
||||
This module don't use a .env file as a configuration file. We are now using YAML files with a Symfony service container to configure services and their injected dependencies as well as configuration parameters.
|
||||
You can copy and paste the `config.yml.dist` to `config.yml` but you **MUST NOT COMMIT THIS FILE**
|
||||
|
||||
### Composer dependency `prestashop_accounts_auth` deprecated
|
||||
This library will is deprecated and no longer needed.
|
||||
Please remove it from your module's dependencies.
|
||||
|
||||
### New composer dependency `prestashop-accounts-installer`
|
||||
**Do not directly import PrestaShop Accounts classes**
|
||||
|
||||
If you need to call PrestaShop Accounts public classes's methods, you need to use the service container.
|
||||
|
||||
see: [PrestaShop Accounts Installer](http://github.com/PrestaShopCorp/prestashop-accounts-installer)
|
||||
|
||||
175
modules/ps_accounts/classes/Adapter/Configuration.php
Normal file
175
modules/ps_accounts/classes/Adapter/Configuration.php
Normal file
@@ -0,0 +1,175 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Adapter;
|
||||
|
||||
class Configuration
|
||||
{
|
||||
const PS_ACCOUNTS_FIREBASE_ID_TOKEN = 'PS_ACCOUNTS_FIREBASE_ID_TOKEN';
|
||||
const PS_PSX_FIREBASE_ID_TOKEN = 'PS_PSX_FIREBASE_ID_TOKEN';
|
||||
const PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN = 'PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN';
|
||||
const PS_PSX_FIREBASE_REFRESH_TOKEN = 'PS_PSX_FIREBASE_REFRESH_TOKEN';
|
||||
const PS_CHECKOUT_SHOP_UUID_V4 = 'PS_CHECKOUT_SHOP_UUID_V4';
|
||||
const PSX_UUID_V4 = 'PSX_UUID_V4';
|
||||
const PS_PSX_FIREBASE_ADMIN_TOKEN = 'PS_PSX_FIREBASE_ADMIN_TOKEN';
|
||||
const PS_ACCOUNTS_FIREBASE_ADMIN_TOKEN = 'PS_ACCOUNTS_FIREBASE_ADMIN_TOKEN';
|
||||
const PS_PSX_FIREBASE_REFRESH_DATE = 'PS_PSX_FIREBASE_REFRESH_DATE';
|
||||
const PS_PSX_FIREBASE_EMAIL = 'PS_PSX_FIREBASE_EMAIL';
|
||||
const PS_ACCOUNTS_FIREBASE_EMAIL = 'PS_ACCOUNTS_FIREBASE_EMAIL';
|
||||
const PS_PSX_FIREBASE_EMAIL_IS_VERIFIED = 'PS_PSX_FIREBASE_EMAIL_IS_VERIFIED';
|
||||
const PS_ACCOUNTS_FIREBASE_EMAIL_IS_VERIFIED = 'PS_ACCOUNTS_FIREBASE_EMAIL_IS_VERIFIED';
|
||||
const PS_PSX_FIREBASE_LOCAL_ID = 'PS_PSX_FIREBASE_LOCAL_ID';
|
||||
const PS_ACCOUNTS_FIREBASE_LOCAL_ID = 'PS_ACCOUNTS_FIREBASE_LOCAL_ID';
|
||||
const PS_ACCOUNTS_RSA_PUBLIC_KEY = 'PS_ACCOUNTS_RSA_PUBLIC_KEY';
|
||||
const PS_ACCOUNTS_RSA_PRIVATE_KEY = 'PS_ACCOUNTS_RSA_PRIVATE_KEY';
|
||||
const PS_ACCOUNTS_RSA_SIGN_DATA = 'PS_ACCOUNTS_RSA_SIGN_DATA';
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $idShop = null;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $idShopGroup = null;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $idLang = null;
|
||||
|
||||
/**
|
||||
* Configuration constructor.
|
||||
*
|
||||
* @param \Context $context
|
||||
*/
|
||||
public function __construct(\Context $context)
|
||||
{
|
||||
$this->setIdShop((int) $context->shop->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getIdShop()
|
||||
{
|
||||
return $this->idShop;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $idShop
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setIdShop($idShop)
|
||||
{
|
||||
$this->idShop = $idShop;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getIdShopGroup()
|
||||
{
|
||||
return $this->idShopGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $idShopGroup
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setIdShopGroup($idShopGroup)
|
||||
{
|
||||
$this->idShopGroup = $idShopGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getIdLang()
|
||||
{
|
||||
return $this->idLang;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $idLang
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setIdLang($idLang)
|
||||
{
|
||||
$this->idLang = $idLang;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @param string|bool $default
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key, $default = false)
|
||||
{
|
||||
return $this->getRaw($key, $this->idLang, $this->idShopGroup, $this->idShop, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @param int|null $idLang
|
||||
* @param int|null $idShopGroup
|
||||
* @param int|null $idShop
|
||||
* @param string|bool $default
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getRaw($key, $idLang = null, $idShopGroup = null, $idShop = null, $default = false)
|
||||
{
|
||||
$value = \Configuration::get($key, $idLang, $idShopGroup, $idShop);
|
||||
|
||||
return $value ?: ($default !== false ? $default : $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @param string|array $values
|
||||
* @param bool $html
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function set($key, $values, $html = false)
|
||||
{
|
||||
return $this->setRaw($key, $values, $html, $this->idShopGroup, $this->idShop);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @param string|array $values
|
||||
* @param bool $html
|
||||
* @param int|null $idShopGroup
|
||||
* @param int|null $idShop
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function setRaw($key, $values, $html = false, $idShopGroup = null, $idShop = null)
|
||||
{
|
||||
return \Configuration::updateValue($key, $values, $html, $idShopGroup, $idShop);
|
||||
}
|
||||
}
|
||||
87
modules/ps_accounts/classes/Adapter/Link.php
Normal file
87
modules/ps_accounts/classes/Adapter/Link.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Adapter;
|
||||
|
||||
use PrestaShop\Module\PsAccounts\Context\ShopContext;
|
||||
|
||||
/**
|
||||
* Link adapter
|
||||
*/
|
||||
class Link
|
||||
{
|
||||
/**
|
||||
* @var ShopContext
|
||||
*/
|
||||
private $shopContext;
|
||||
|
||||
/**
|
||||
* Link object
|
||||
*
|
||||
* @var \Link
|
||||
*/
|
||||
private $link;
|
||||
|
||||
public function __construct(
|
||||
ShopContext $shopContext,
|
||||
\Link $link = null
|
||||
) {
|
||||
if (null === $link) {
|
||||
$link = new \Link();
|
||||
}
|
||||
|
||||
$this->shopContext = $shopContext;
|
||||
|
||||
$this->link = $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapter for getAdminLink from prestashop link class
|
||||
*
|
||||
* @param string $controller controller name
|
||||
* @param bool $withToken include or not the token in the url
|
||||
* @param array $sfRouteParams
|
||||
* @param array $params
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \PrestaShopException
|
||||
*/
|
||||
public function getAdminLink($controller, $withToken = true, $sfRouteParams = [], $params = [])
|
||||
{
|
||||
if ($this->shopContext->isShop17()) {
|
||||
return $this->link->getAdminLink($controller, $withToken, $sfRouteParams, $params);
|
||||
}
|
||||
$paramsAsString = '';
|
||||
foreach ($params as $key => $value) {
|
||||
$paramsAsString .= "&$key=$value";
|
||||
}
|
||||
|
||||
return \Tools::getShopDomainSsl(true) . __PS_BASE_URI__ . basename(_PS_ADMIN_DIR_) . '/' . $this->link->getAdminLink($controller, $withToken) . $paramsAsString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Link
|
||||
*/
|
||||
public function getLink()
|
||||
{
|
||||
return $this->link;
|
||||
}
|
||||
}
|
||||
28
modules/ps_accounts/classes/Adapter/index.php
Normal file
28
modules/ps_accounts/classes/Adapter/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
120
modules/ps_accounts/classes/Api/Client/FirebaseClient.php
Normal file
120
modules/ps_accounts/classes/Api/Client/FirebaseClient.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Api\Client;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use PrestaShop\Module\PsAccounts\Configuration\ConfigOptionsResolver;
|
||||
use PrestaShop\Module\PsAccounts\Exception\OptionResolutionException;
|
||||
|
||||
/**
|
||||
* Handle firebase signIn/signUp.
|
||||
*/
|
||||
class FirebaseClient extends GenericClient
|
||||
{
|
||||
/**
|
||||
* Firebase api key.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $apiKey;
|
||||
|
||||
/**
|
||||
* FirebaseClient constructor.
|
||||
*
|
||||
* @param array $config
|
||||
*
|
||||
* @throws OptionResolutionException
|
||||
*/
|
||||
public function __construct(array $config)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$config = $this->resolveConfig($config);
|
||||
|
||||
$client = new Client([
|
||||
'defaults' => [
|
||||
'timeout' => $this->timeout,
|
||||
'exceptions' => $this->catchExceptions,
|
||||
'allow_redirects' => false,
|
||||
'query' => [
|
||||
'key' => $config['api_key'],
|
||||
],
|
||||
'headers' => [
|
||||
'Accept' => 'application/json',
|
||||
'Content-Type' => 'application/json',
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$this->setClient($client);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $customToken
|
||||
*
|
||||
* @return array response
|
||||
*/
|
||||
public function signInWithCustomToken($customToken)
|
||||
{
|
||||
$this->setRoute('https://identitytoolkit.googleapis.com/v1/accounts:signInWithCustomToken');
|
||||
|
||||
return $this->post([
|
||||
'json' => [
|
||||
'token' => $customToken,
|
||||
'returnSecureToken' => true,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://firebase.google.com/docs/reference/rest/auth#section-refresh-token Firebase documentation
|
||||
*
|
||||
* @param string $refreshToken
|
||||
*
|
||||
* @return array response
|
||||
*/
|
||||
public function exchangeRefreshTokenForIdToken($refreshToken)
|
||||
{
|
||||
$this->setRoute('https://securetoken.googleapis.com/v1/token');
|
||||
|
||||
return $this->post([
|
||||
'json' => [
|
||||
'grant_type' => 'refresh_token',
|
||||
'refresh_token' => $refreshToken,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $config
|
||||
* @param array $defaults
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws OptionResolutionException
|
||||
*/
|
||||
public function resolveConfig(array $config, array $defaults = [])
|
||||
{
|
||||
return (new ConfigOptionsResolver([
|
||||
'api_key',
|
||||
]))->resolve($config, $defaults);
|
||||
}
|
||||
}
|
||||
287
modules/ps_accounts/classes/Api/Client/GenericClient.php
Normal file
287
modules/ps_accounts/classes/Api/Client/GenericClient.php
Normal file
@@ -0,0 +1,287 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Api\Client;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use PrestaShop\Module\PsAccounts\Configuration\Configurable;
|
||||
use PrestaShop\Module\PsAccounts\Handler\Response\ApiResponseHandler;
|
||||
|
||||
/**
|
||||
* Construct the client used to make call to maasland.
|
||||
*/
|
||||
abstract class GenericClient implements Configurable
|
||||
{
|
||||
/**
|
||||
* If set to false, you will not be able to catch the error
|
||||
* guzzle will show a different error message.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $catchExceptions = false;
|
||||
/**
|
||||
* Guzzle Client.
|
||||
*
|
||||
* @var Client
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* Class Link in order to generate module link.
|
||||
*
|
||||
* @var \Link
|
||||
*/
|
||||
protected $link;
|
||||
|
||||
/**
|
||||
* Api route.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $route;
|
||||
|
||||
/**
|
||||
* Set how long guzzle will wait a response before end it up.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $timeout = 10;
|
||||
|
||||
/**
|
||||
* GenericClient constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for client.
|
||||
*
|
||||
* @return Client
|
||||
*/
|
||||
protected function getClient()
|
||||
{
|
||||
return $this->client;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for exceptions mode.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function getExceptionsMode()
|
||||
{
|
||||
return $this->catchExceptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for Link.
|
||||
*
|
||||
* @return \Link
|
||||
*/
|
||||
protected function getLink()
|
||||
{
|
||||
return $this->link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for route.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getRoute()
|
||||
{
|
||||
return $this->route;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for timeout.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function getTimeout()
|
||||
{
|
||||
return $this->timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper of method post from guzzle client.
|
||||
*
|
||||
* @param array $options payload
|
||||
*
|
||||
* @return array return response or false if no response
|
||||
*/
|
||||
protected function post(array $options = [])
|
||||
{
|
||||
$response = $this->getClient()->post($this->getRoute(), $options);
|
||||
$responseHandler = new ApiResponseHandler();
|
||||
$response = $responseHandler->handleResponse($response);
|
||||
// If response is not successful only
|
||||
if (\Configuration::get('PS_ACCOUNTS_DEBUG_LOGS_ENABLED') && !$response['status']) {
|
||||
/**
|
||||
* @var \Ps_accounts
|
||||
*/
|
||||
$module = \Module::getInstanceByName('ps_accounts');
|
||||
$logger = $module->getLogger();
|
||||
$logger->debug('route ' . $this->getRoute());
|
||||
$logger->debug('options ' . var_export($options, true));
|
||||
$logger->debug('response ' . var_export($response, true));
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper of method patch from guzzle client.
|
||||
*
|
||||
* @param array $options payload
|
||||
*
|
||||
* @return array return response or false if no response
|
||||
*/
|
||||
protected function patch(array $options = [])
|
||||
{
|
||||
$response = $this->getClient()->patch($this->getRoute(), $options);
|
||||
$responseHandler = new ApiResponseHandler();
|
||||
$response = $responseHandler->handleResponse($response);
|
||||
// If response is not successful only
|
||||
if (\Configuration::get('PS_ACCOUNTS_DEBUG_LOGS_ENABLED') && !$response['status']) {
|
||||
/**
|
||||
* @var \Ps_accounts
|
||||
*/
|
||||
$module = \Module::getInstanceByName('ps_accounts');
|
||||
$logger = $module->getLogger();
|
||||
$logger->debug('route ' . $this->getRoute());
|
||||
$logger->debug('options ' . var_export($options, true));
|
||||
$logger->debug('response ' . var_export($response, true));
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper of method post from guzzle client.
|
||||
*
|
||||
* @param array $options payload
|
||||
*
|
||||
* @return array return response or false if no response
|
||||
*/
|
||||
protected function get(array $options = [])
|
||||
{
|
||||
$response = $this->getClient()->get($this->getRoute(), $options);
|
||||
$responseHandler = new ApiResponseHandler();
|
||||
$response = $responseHandler->handleResponse($response);
|
||||
// If response is not successful only
|
||||
if (\Configuration::get('PS_ACCOUNTS_DEBUG_LOGS_ENABLED') && !$response['status']) {
|
||||
/**
|
||||
* @var \Ps_accounts
|
||||
*/
|
||||
$module = \Module::getInstanceByName('ps_accounts');
|
||||
$logger = $module->getLogger();
|
||||
$logger->debug('route ' . $this->getRoute());
|
||||
$logger->debug('options ' . var_export($options, true));
|
||||
$logger->debug('response ' . var_export($response, true));
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper of method delete from guzzle client.
|
||||
*
|
||||
* @param array $options payload
|
||||
*
|
||||
* @return array return response array
|
||||
*/
|
||||
protected function delete(array $options = [])
|
||||
{
|
||||
$response = $this->getClient()->delete($this->getRoute(), $options);
|
||||
$responseHandler = new ApiResponseHandler();
|
||||
$response = $responseHandler->handleResponse($response);
|
||||
// If response is not successful only
|
||||
if (\Configuration::get('PS_ACCOUNTS_DEBUG_LOGS_ENABLED') && !$response['status']) {
|
||||
/**
|
||||
* @var \Ps_accounts
|
||||
*/
|
||||
$module = \Module::getInstanceByName('ps_accounts');
|
||||
$logger = $module->getLogger();
|
||||
$logger->debug('route ' . $this->getRoute());
|
||||
$logger->debug('options ' . var_export($options, true));
|
||||
$logger->debug('response ' . var_export($response, true));
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for client.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setClient(Client $client)
|
||||
{
|
||||
$this->client = $client;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for exceptions mode.
|
||||
*
|
||||
* @param bool $bool
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setExceptionsMode($bool)
|
||||
{
|
||||
$this->catchExceptions = $bool;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for link.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setLink(\Link $link)
|
||||
{
|
||||
$this->link = $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for route.
|
||||
*
|
||||
* @param string $route
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setRoute($route)
|
||||
{
|
||||
$this->route = $route;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for timeout.
|
||||
*
|
||||
* @param int $timeout
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setTimeout($timeout)
|
||||
{
|
||||
$this->timeout = $timeout;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Api\Client;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use PrestaShop\Module\PsAccounts\Adapter\Link;
|
||||
use PrestaShop\Module\PsAccounts\Configuration\ConfigOptionsResolver;
|
||||
use PrestaShop\Module\PsAccounts\Exception\OptionResolutionException;
|
||||
use PrestaShop\Module\PsAccounts\Exception\TokenNotFoundException;
|
||||
use PrestaShop\Module\PsAccounts\Provider\ShopProvider;
|
||||
use PrestaShop\Module\PsAccounts\Service\ShopTokenService;
|
||||
|
||||
/**
|
||||
* Class ServicesAccountsClient
|
||||
*/
|
||||
class ServicesAccountsClient extends GenericClient
|
||||
{
|
||||
/**
|
||||
* @var ShopProvider
|
||||
*/
|
||||
private $shopProvider;
|
||||
|
||||
/**
|
||||
* @var ShopTokenService
|
||||
*/
|
||||
private $shopTokenService;
|
||||
|
||||
/**
|
||||
* ServicesAccountsClient constructor.
|
||||
*
|
||||
* @param array $config
|
||||
* @param ShopProvider $shopProvider
|
||||
* @param ShopTokenService $shopTokenService
|
||||
* @param Link $link
|
||||
* @param Client|null $client
|
||||
*
|
||||
* @throws OptionResolutionException
|
||||
* @throws TokenNotFoundException
|
||||
* @throws \PrestaShopException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct(
|
||||
array $config,
|
||||
ShopProvider $shopProvider,
|
||||
ShopTokenService $shopTokenService,
|
||||
Link $link,
|
||||
Client $client = null
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$config = $this->resolveConfig($config);
|
||||
|
||||
$this->shopProvider = $shopProvider;
|
||||
$this->shopTokenService = $shopTokenService;
|
||||
|
||||
$shopId = (int) $this->shopProvider->getCurrentShop()['id'];
|
||||
$token = $this->shopTokenService->getOrRefreshToken();
|
||||
|
||||
$this->setLink($link->getLink());
|
||||
|
||||
if (!$token) {
|
||||
throw new TokenNotFoundException('Firebase token not found');
|
||||
}
|
||||
|
||||
// Client can be provided for tests
|
||||
if (null === $client) {
|
||||
$client = new Client([
|
||||
'base_url' => $config['api_url'],
|
||||
'defaults' => [
|
||||
'timeout' => $this->timeout,
|
||||
'exceptions' => $this->catchExceptions,
|
||||
'headers' => [
|
||||
// Commented, else does not work anymore with API.
|
||||
//'Content-Type' => 'application/vnd.accounts.v1+json', // api version to use
|
||||
'Accept' => 'application/json',
|
||||
'Authorization' => 'Bearer ' . $token,
|
||||
'Shop-Id' => $shopId,
|
||||
'Module-Version' => \Ps_accounts::VERSION, // version of the module
|
||||
'Prestashop-Version' => _PS_VERSION_, // prestashop version
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
$this->setClient($client);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $shopUuidV4
|
||||
* @param array $bodyHttp
|
||||
*
|
||||
* @return array | false
|
||||
*/
|
||||
public function updateShopUrl($shopUuidV4, $bodyHttp)
|
||||
{
|
||||
$this->setRoute('/shops/' . $shopUuidV4 . '/url');
|
||||
|
||||
return $this->patch([
|
||||
'body' => $bodyHttp,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $shopUuidV4
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function deleteShop($shopUuidV4)
|
||||
{
|
||||
$this->setRoute('/shop/' . $shopUuidV4);
|
||||
|
||||
return $this->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $headers
|
||||
* @param array $body
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \PrestaShopException
|
||||
*/
|
||||
public function verifyWebhook(array $headers, array $body)
|
||||
{
|
||||
$correlationId = $headers['correlationId'];
|
||||
|
||||
$this->setRoute('/webhooks/' . $correlationId . '/verify');
|
||||
|
||||
$shopId = (int) $this->shopProvider->getCurrentShop()['id'];
|
||||
$hookUrl = $this->link->getModuleLink('ps_accounts', 'DispatchWebHook', [], true, null, $shopId);
|
||||
|
||||
$res = $this->post([
|
||||
'headers' => [
|
||||
'correlationId' => $correlationId,
|
||||
'Hook-Url' => $hookUrl,
|
||||
],
|
||||
'json' => $body,
|
||||
]);
|
||||
|
||||
if (!$res || $res['httpCode'] < 200 || $res['httpCode'] > 299) {
|
||||
return [
|
||||
'httpCode' => $res['httpCode'],
|
||||
'body' => $res['body']
|
||||
&& is_array($res['body'])
|
||||
&& array_key_exists('message', $res['body'])
|
||||
? $res['body']['message']
|
||||
: 'Unknown error',
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'httpCode' => 200,
|
||||
'body' => 'ok',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $config
|
||||
* @param array $defaults
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws OptionResolutionException
|
||||
*/
|
||||
public function resolveConfig(array $config, array $defaults = [])
|
||||
{
|
||||
return (new ConfigOptionsResolver([
|
||||
'api_url',
|
||||
]))->resolve($config, $defaults);
|
||||
}
|
||||
}
|
||||
158
modules/ps_accounts/classes/Api/Client/ServicesBillingClient.php
Normal file
158
modules/ps_accounts/classes/Api/Client/ServicesBillingClient.php
Normal file
@@ -0,0 +1,158 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Api\Client;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use PrestaShop\Module\PsAccounts\Adapter\Link;
|
||||
use PrestaShop\Module\PsAccounts\Configuration\ConfigOptionsResolver;
|
||||
use PrestaShop\Module\PsAccounts\Exception\OptionResolutionException;
|
||||
use PrestaShop\Module\PsAccounts\Provider\ShopProvider;
|
||||
use PrestaShop\Module\PsAccounts\Service\PsAccountsService;
|
||||
|
||||
/**
|
||||
* Handle call api Services
|
||||
*/
|
||||
class ServicesBillingClient extends GenericClient
|
||||
{
|
||||
/**
|
||||
* ServicesBillingClient constructor.
|
||||
*
|
||||
* @param array $config
|
||||
* @param PsAccountsService $psAccountsService
|
||||
* @param ShopProvider $shopProvider
|
||||
* @param Link $link
|
||||
* @param Client|null $client
|
||||
*
|
||||
* @throws OptionResolutionException
|
||||
* @throws \PrestaShopException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct(
|
||||
array $config,
|
||||
PsAccountsService $psAccountsService,
|
||||
ShopProvider $shopProvider,
|
||||
Link $link,
|
||||
Client $client = null
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$config = $this->resolveConfig($config);
|
||||
|
||||
$shopId = $shopProvider->getCurrentShop()['id'];
|
||||
|
||||
$token = $psAccountsService->getOrRefreshToken();
|
||||
|
||||
$this->setLink($link->getLink());
|
||||
|
||||
// Client can be provided for tests
|
||||
if (null === $client) {
|
||||
$client = new Client([
|
||||
'base_url' => $config['api_url'],
|
||||
'defaults' => [
|
||||
'timeout' => $this->timeout,
|
||||
'exceptions' => $this->catchExceptions,
|
||||
'headers' => [
|
||||
// Commented, else does not work anymore with API.
|
||||
//'Content-Type' => 'application/vnd.accounts.v1+json', // api version to use
|
||||
'Accept' => 'application/json',
|
||||
'Authorization' => 'Bearer ' . $token,
|
||||
'Shop-Id' => $shopId,
|
||||
'Module-Version' => \Ps_accounts::VERSION, // version of the module
|
||||
'Prestashop-Version' => _PS_VERSION_, // prestashop version
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
$this->setClient($client);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $shopUuidV4
|
||||
*
|
||||
* @return array | false
|
||||
*/
|
||||
public function getBillingCustomer($shopUuidV4)
|
||||
{
|
||||
$this->setRoute('/shops/' . $shopUuidV4);
|
||||
|
||||
return $this->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $shopUuidV4
|
||||
* @param array $bodyHttp
|
||||
*
|
||||
* @return array | false
|
||||
*/
|
||||
public function createBillingCustomer($shopUuidV4, $bodyHttp)
|
||||
{
|
||||
$this->setRoute('/shops/' . $shopUuidV4);
|
||||
|
||||
return $this->post([
|
||||
'body' => $bodyHttp,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $shopUuidV4
|
||||
* @param string $module
|
||||
*
|
||||
* @return array | false
|
||||
*/
|
||||
public function getBillingSubscriptions($shopUuidV4, $module)
|
||||
{
|
||||
$this->setRoute('/shops/' . $shopUuidV4 . '/subscriptions/' . $module);
|
||||
|
||||
return $this->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $shopUuidV4
|
||||
* @param string $module
|
||||
* @param array $bodyHttp
|
||||
*
|
||||
* @return array | false
|
||||
*/
|
||||
public function createBillingSubscriptions($shopUuidV4, $module, $bodyHttp)
|
||||
{
|
||||
$this->setRoute('/shops/' . $shopUuidV4 . '/subscriptions/' . $module);
|
||||
|
||||
return $this->post([
|
||||
'body' => $bodyHttp,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $config
|
||||
* @param array $defaults
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws OptionResolutionException
|
||||
*/
|
||||
public function resolveConfig(array $config, array $defaults = [])
|
||||
{
|
||||
return (new ConfigOptionsResolver([
|
||||
'api_url',
|
||||
]))->resolve($config, $defaults);
|
||||
}
|
||||
}
|
||||
28
modules/ps_accounts/classes/Api/Client/index.php
Normal file
28
modules/ps_accounts/classes/Api/Client/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
28
modules/ps_accounts/classes/Api/index.php
Normal file
28
modules/ps_accounts/classes/Api/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Configuration;
|
||||
|
||||
use PrestaShop\Module\PsAccounts\Exception\OptionResolutionException;
|
||||
|
||||
class ConfigOptionsResolver
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $required;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $defaults;
|
||||
|
||||
public function __construct(array $required, array $defaults = [])
|
||||
{
|
||||
$this->required = $required;
|
||||
|
||||
$this->defaults = $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $config
|
||||
* @param array $defaults
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws OptionResolutionException
|
||||
*/
|
||||
public function resolve(array $config, array $defaults = [])
|
||||
{
|
||||
$defaults = array_merge($this->defaults, $defaults);
|
||||
|
||||
$diff = array_diff($this->required, array_keys($config), array_keys($defaults));
|
||||
|
||||
if (count($diff) > 0) {
|
||||
throw new OptionResolutionException('Configuration option missing : [' . array_shift($diff) . ']');
|
||||
}
|
||||
|
||||
$config = array_merge($defaults, $config);
|
||||
|
||||
//error_log('#### config ' . print_r($config, true));
|
||||
|
||||
return $config;
|
||||
}
|
||||
}
|
||||
36
modules/ps_accounts/classes/Configuration/Configurable.php
Normal file
36
modules/ps_accounts/classes/Configuration/Configurable.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Configuration;
|
||||
|
||||
use PrestaShop\Module\PsAccounts\Exception\OptionResolutionException;
|
||||
|
||||
interface Configurable
|
||||
{
|
||||
/**
|
||||
* @param array $config
|
||||
* @param array $defaults
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws OptionResolutionException
|
||||
*/
|
||||
public function resolveConfig(array $config, array $defaults = []);
|
||||
}
|
||||
28
modules/ps_accounts/classes/Configuration/index.php
Normal file
28
modules/ps_accounts/classes/Configuration/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
114
modules/ps_accounts/classes/Context/ShopContext.php
Normal file
114
modules/ps_accounts/classes/Context/ShopContext.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Context;
|
||||
|
||||
use Context;
|
||||
use PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository;
|
||||
|
||||
/**
|
||||
* Get the shop context
|
||||
*/
|
||||
class ShopContext
|
||||
{
|
||||
/**
|
||||
* @var ConfigurationRepository
|
||||
*/
|
||||
private $configuration;
|
||||
|
||||
/**
|
||||
* @var Context
|
||||
*/
|
||||
private $context;
|
||||
|
||||
/**
|
||||
* ShopContext constructor.
|
||||
*
|
||||
* @param ConfigurationRepository $configuration
|
||||
* @param Context $context
|
||||
*/
|
||||
public function __construct(
|
||||
ConfigurationRepository $configuration,
|
||||
Context $context
|
||||
) {
|
||||
$this->configuration = $configuration;
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isShop17()
|
||||
{
|
||||
return version_compare(_PS_VERSION_, '1.7.0.0', '>=');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isShop173()
|
||||
{
|
||||
return version_compare(_PS_VERSION_, '1.7.3.0', '>=');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isShopContext()
|
||||
{
|
||||
if (\Shop::isFeatureActive() && \Shop::getContext() !== \Shop::CONTEXT_SHOP) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function sslEnabled()
|
||||
{
|
||||
return $this->configuration->sslEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProtocol()
|
||||
{
|
||||
return false == $this->sslEnabled() ? 'http' : 'https';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Context
|
||||
*/
|
||||
public function getContext()
|
||||
{
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ConfigurationRepository
|
||||
*/
|
||||
public function getConfiguration()
|
||||
{
|
||||
return $this->configuration;
|
||||
}
|
||||
}
|
||||
28
modules/ps_accounts/classes/Context/index.php
Normal file
28
modules/ps_accounts/classes/Context/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\DependencyInjection;
|
||||
|
||||
use PrestaShop\ModuleLibCacheDirectoryProvider\Cache\CacheDirectoryProvider;
|
||||
use Symfony\Component\Config\ConfigCache;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
|
||||
class ContainerProvider
|
||||
{
|
||||
/**
|
||||
* @var string Module Name
|
||||
*/
|
||||
private $moduleName;
|
||||
|
||||
/**
|
||||
* @var string Module Local Path
|
||||
*/
|
||||
private $moduleLocalPath;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $moduleEnv;
|
||||
|
||||
/**
|
||||
* @var CacheDirectoryProvider
|
||||
*/
|
||||
private $cacheDirectory;
|
||||
|
||||
/**
|
||||
* @param string $moduleName
|
||||
* @param string $moduleLocalPath
|
||||
* @param string $moduleEnv
|
||||
* @param CacheDirectoryProvider $cacheDirectory
|
||||
*/
|
||||
public function __construct(
|
||||
$moduleName,
|
||||
$moduleLocalPath,
|
||||
$moduleEnv,
|
||||
CacheDirectoryProvider $cacheDirectory
|
||||
) {
|
||||
$this->moduleName = $moduleName;
|
||||
$this->moduleLocalPath = $moduleLocalPath;
|
||||
$this->moduleEnv = $moduleEnv;
|
||||
$this->cacheDirectory = $cacheDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $containerName
|
||||
*
|
||||
* @return ContainerInterface
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function get($containerName)
|
||||
{
|
||||
$containerClassName = ucfirst($this->moduleName)
|
||||
. ucfirst($containerName)
|
||||
. 'Container'
|
||||
;
|
||||
$containerFilePath = $this->cacheDirectory->getPath() . '/' . $containerClassName . '.php';
|
||||
$containerConfigCache = new ConfigCache($containerFilePath, _PS_MODE_DEV_);
|
||||
|
||||
if ($containerConfigCache->isFresh()) {
|
||||
require_once $containerFilePath;
|
||||
|
||||
return new $containerClassName();
|
||||
}
|
||||
|
||||
$containerBuilder = new ContainerBuilder();
|
||||
$containerBuilder->set(
|
||||
$this->moduleName . '.cache.directory',
|
||||
$this->cacheDirectory
|
||||
);
|
||||
$moduleConfigPath = $this->moduleLocalPath
|
||||
. 'config/'
|
||||
. $containerName
|
||||
;
|
||||
|
||||
$loader = new YamlFileLoader($containerBuilder, new FileLocator($moduleConfigPath));
|
||||
|
||||
$loader->load('services' . ($this->moduleEnv ? '_' . $this->moduleEnv : '') . '.yml');
|
||||
|
||||
$containerBuilder->compile();
|
||||
$dumper = new PhpDumper($containerBuilder);
|
||||
$containerConfigCache->write(
|
||||
$dumper->dump(['class' => $containerClassName]),
|
||||
$containerBuilder->getResources()
|
||||
);
|
||||
|
||||
return $containerBuilder;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\DependencyInjection;
|
||||
|
||||
use PrestaShop\ModuleLibCacheDirectoryProvider\Cache\CacheDirectoryProvider;
|
||||
//use PrestaShop\ModuleLibServiceContainer\DependencyInjection\ContainerProvider;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
class ServiceContainer
|
||||
{
|
||||
/**
|
||||
* @var string Module Name
|
||||
*/
|
||||
private $moduleName;
|
||||
|
||||
/**
|
||||
* @var string Module Local Path
|
||||
*/
|
||||
private $moduleLocalPath;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $moduleEnv;
|
||||
|
||||
/**
|
||||
* @var ContainerInterface
|
||||
*/
|
||||
private $container;
|
||||
|
||||
/**
|
||||
* @param string $moduleName
|
||||
* @param string $moduleLocalPath
|
||||
* @param string $moduleEnv
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct($moduleName, $moduleLocalPath, $moduleEnv)
|
||||
{
|
||||
$this->moduleName = $moduleName;
|
||||
$this->moduleLocalPath = $moduleLocalPath;
|
||||
$this->moduleEnv = $moduleEnv;
|
||||
|
||||
$this->initContainer();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $serviceName
|
||||
*
|
||||
* @return object|null
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getService($serviceName)
|
||||
{
|
||||
if (null === $this->container) {
|
||||
$this->initContainer();
|
||||
}
|
||||
|
||||
return $this->container->get($serviceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ContainerInterface
|
||||
*/
|
||||
public function getContainer()
|
||||
{
|
||||
return $this->container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate a new ContainerProvider
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function initContainer()
|
||||
{
|
||||
$cacheDirectory = new CacheDirectoryProvider(
|
||||
_PS_VERSION_,
|
||||
_PS_ROOT_DIR_,
|
||||
_PS_MODE_DEV_
|
||||
);
|
||||
$containerProvider = new ContainerProvider($this->moduleName, $this->moduleLocalPath, $this->moduleEnv, $cacheDirectory);
|
||||
|
||||
$this->container = $containerProvider->get(defined('_PS_ADMIN_DIR_') || defined('PS_INSTALLATION_IN_PROGRESS') ? 'admin' : 'front');
|
||||
}
|
||||
}
|
||||
28
modules/ps_accounts/classes/DependencyInjection/index.php
Normal file
28
modules/ps_accounts/classes/DependencyInjection/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
25
modules/ps_accounts/classes/Exception/BillingException.php
Normal file
25
modules/ps_accounts/classes/Exception/BillingException.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Exception;
|
||||
|
||||
class BillingException extends \Exception
|
||||
{
|
||||
}
|
||||
25
modules/ps_accounts/classes/Exception/HmacException.php
Normal file
25
modules/ps_accounts/classes/Exception/HmacException.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Exception;
|
||||
|
||||
class HmacException extends \Exception
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Exception;
|
||||
|
||||
class OptionResolutionException extends \Exception
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Exception;
|
||||
|
||||
class QueryParamsException extends \Exception
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Exception;
|
||||
|
||||
class RsaSignedDataNotFoundException extends \Exception
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Exception;
|
||||
|
||||
class SshKeysNotFoundException extends \Exception
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Exception;
|
||||
|
||||
class TokenNotFoundException extends \Exception
|
||||
{
|
||||
}
|
||||
25
modules/ps_accounts/classes/Exception/WebhookException.php
Normal file
25
modules/ps_accounts/classes/Exception/WebhookException.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Exception;
|
||||
|
||||
class WebhookException extends \Exception
|
||||
{
|
||||
}
|
||||
28
modules/ps_accounts/classes/Exception/index.php
Normal file
28
modules/ps_accounts/classes/Exception/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
54
modules/ps_accounts/classes/Factory/PsAccountsLogger.php
Normal file
54
modules/ps_accounts/classes/Factory/PsAccountsLogger.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Factory;
|
||||
|
||||
use Monolog\Handler\RotatingFileHandler;
|
||||
use Monolog\Logger;
|
||||
|
||||
class PsAccountsLogger
|
||||
{
|
||||
const MAX_FILES = 15;
|
||||
|
||||
/**
|
||||
* Create logger.
|
||||
*
|
||||
* @return \Monolog\Logger
|
||||
*/
|
||||
public static function create()
|
||||
{
|
||||
$path = _PS_ROOT_DIR_ . '/var/logs/ps_accounts';
|
||||
|
||||
if (version_compare(_PS_VERSION_, '1.7', '<')) {
|
||||
$path = _PS_ROOT_DIR_ . '/log/ps_accounts';
|
||||
} elseif (version_compare(_PS_VERSION_, '1.7.4', '<')) {
|
||||
$path = _PS_ROOT_DIR_ . '/app/logs/ps_accounts';
|
||||
}
|
||||
|
||||
$rotatingFileHandler = new RotatingFileHandler(
|
||||
$path,
|
||||
static::MAX_FILES
|
||||
);
|
||||
$logger = new Logger('ps_accounts');
|
||||
$logger->pushHandler($rotatingFileHandler);
|
||||
|
||||
return $logger;
|
||||
}
|
||||
}
|
||||
28
modules/ps_accounts/classes/Factory/index.php
Normal file
28
modules/ps_accounts/classes/Factory/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
124
modules/ps_accounts/classes/Handler/Error/Sentry.php
Normal file
124
modules/ps_accounts/classes/Handler/Error/Sentry.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Handler\Error;
|
||||
|
||||
use Module;
|
||||
use PrestaShop\Module\PsAccounts\Adapter\Configuration;
|
||||
use PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository;
|
||||
use Ps_accounts;
|
||||
use Raven_Client;
|
||||
|
||||
/**
|
||||
* Handle Error.
|
||||
*/
|
||||
class Sentry
|
||||
{
|
||||
/**
|
||||
* @var Raven_Client
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* @var ConfigurationRepository
|
||||
*/
|
||||
private $configuration;
|
||||
|
||||
/**
|
||||
* ErrorHandler constructor.
|
||||
*
|
||||
* @param string $sentryCredentials
|
||||
* @param string $environment
|
||||
* @param ConfigurationRepository $configuration
|
||||
*
|
||||
* @throws \Raven_Exception
|
||||
*/
|
||||
public function __construct(
|
||||
$sentryCredentials,
|
||||
$environment,
|
||||
ConfigurationRepository $configuration
|
||||
) {
|
||||
$this->configuration = $configuration;
|
||||
|
||||
$this->client = new Raven_Client(
|
||||
$sentryCredentials,
|
||||
[
|
||||
'level' => 'warning',
|
||||
'tags' => [
|
||||
'environment' => $environment,
|
||||
'php_version' => phpversion(),
|
||||
'ps_accounts_version' => \Ps_accounts::VERSION,
|
||||
'prestashop_version' => _PS_VERSION_,
|
||||
'ps_accounts_is_enabled' => \Module::isEnabled('ps_accounts'),
|
||||
'ps_accounts_is_installed' => \Module::isInstalled('ps_accounts'),
|
||||
'email' => $this->configuration->getFirebaseEmail(),
|
||||
Configuration::PS_ACCOUNTS_FIREBASE_ID_TOKEN => $this->configuration->getFirebaseIdToken(),
|
||||
Configuration::PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN => $this->configuration->getFirebaseRefreshToken(),
|
||||
Configuration::PSX_UUID_V4 => $this->configuration->getShopUuid(),
|
||||
Configuration::PS_ACCOUNTS_FIREBASE_EMAIL_IS_VERIFIED => $this->configuration->firebaseEmailIsVerified(),
|
||||
Configuration::PS_ACCOUNTS_FIREBASE_EMAIL => $this->configuration->getFirebaseEmail(),
|
||||
Configuration::PS_ACCOUNTS_RSA_PUBLIC_KEY => $this->configuration->getAccountsRsaPublicKey(),
|
||||
Configuration::PS_ACCOUNTS_RSA_SIGN_DATA => $this->configuration->getAccountsRsaSignData(),
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->client->install();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Throwable $exception
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function capture(\Throwable $exception)
|
||||
{
|
||||
/** @var Ps_accounts $psAccounts */
|
||||
$psAccounts = Module::getInstanceByName('ps_accounts');
|
||||
|
||||
/** @var self $instance */
|
||||
$instance = $psAccounts->getService(self::class);
|
||||
|
||||
$instance->client->captureException($exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Throwable $exception
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public static function captureAndRethrow(\Throwable $exception)
|
||||
{
|
||||
self::capture($exception);
|
||||
|
||||
throw $exception;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
private function __clone()
|
||||
{
|
||||
}
|
||||
}
|
||||
28
modules/ps_accounts/classes/Handler/Error/index.php
Normal file
28
modules/ps_accounts/classes/Handler/Error/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Handler\Response;
|
||||
|
||||
use GuzzleHttp\Message\ResponseInterface;
|
||||
|
||||
/**
|
||||
* Handle api response.
|
||||
*/
|
||||
class ApiResponseHandler
|
||||
{
|
||||
/**
|
||||
* Format api response.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function handleResponse(ResponseInterface $response)
|
||||
{
|
||||
$responseContents = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
return [
|
||||
'status' => $this->responseIsSuccessful($responseContents, $response->getStatusCode()),
|
||||
'httpCode' => $response->getStatusCode(),
|
||||
'body' => $responseContents,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the response is successful or not (response code 200 to 299).
|
||||
*
|
||||
* @param array $responseContents
|
||||
* @param int $httpStatusCode
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function responseIsSuccessful($responseContents, $httpStatusCode)
|
||||
{
|
||||
// Directly return true, no need to check the body for a 204 status code
|
||||
// 204 status code is only send by /payments/order/update
|
||||
if (204 === $httpStatusCode) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return '2' === substr((string) $httpStatusCode, 0, 1) && null !== $responseContents;
|
||||
}
|
||||
}
|
||||
28
modules/ps_accounts/classes/Handler/Response/index.php
Normal file
28
modules/ps_accounts/classes/Handler/Response/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
28
modules/ps_accounts/classes/Handler/index.php
Normal file
28
modules/ps_accounts/classes/Handler/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
173
modules/ps_accounts/classes/Installer/Installer.php
Normal file
173
modules/ps_accounts/classes/Installer/Installer.php
Normal file
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Installer;
|
||||
|
||||
use Module;
|
||||
use PrestaShop\Module\PsAccounts\Adapter\Link;
|
||||
use PrestaShop\Module\PsAccounts\Context\ShopContext;
|
||||
use PrestaShop\Module\PsAccounts\Handler\Error\Sentry;
|
||||
use PrestaShop\PrestaShop\Adapter\SymfonyContainer;
|
||||
use PrestaShop\PrestaShop\Core\Addon\Module\ModuleManagerBuilder;
|
||||
use Tools;
|
||||
|
||||
/**
|
||||
* Install ps_accounts module
|
||||
*/
|
||||
class Installer
|
||||
{
|
||||
/**
|
||||
* @var ShopContext
|
||||
*/
|
||||
private $shopContext;
|
||||
|
||||
/**
|
||||
* @var Link
|
||||
*/
|
||||
private $link;
|
||||
|
||||
/**
|
||||
* Install constructor.
|
||||
*
|
||||
* @param ShopContext $shopContext
|
||||
* @param Link $link
|
||||
*/
|
||||
public function __construct(
|
||||
ShopContext $shopContext,
|
||||
Link $link
|
||||
) {
|
||||
$this->shopContext = $shopContext;
|
||||
|
||||
$this->link = $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $module
|
||||
* @param bool $upgrade
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function installModule($module, $upgrade = true)
|
||||
{
|
||||
if (false === $this->shopContext->isShop17()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$moduleManager = ModuleManagerBuilder::getInstance()->build();
|
||||
|
||||
if (false === $upgrade && true === $moduleManager->isInstalled($module)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// install or upgrade module
|
||||
$moduleIsInstalled = $moduleManager->install($module);
|
||||
|
||||
if (false === $moduleIsInstalled) {
|
||||
Sentry::capture(new \Exception("Module ${module} can't be installed"));
|
||||
}
|
||||
|
||||
return $moduleIsInstalled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $module
|
||||
* @param string $psxName
|
||||
*
|
||||
* @return string | null
|
||||
*
|
||||
* @throws \PrestaShopException
|
||||
*/
|
||||
public function getInstallUrl($module, $psxName)
|
||||
{
|
||||
if ($this->shopContext->isShop17()) {
|
||||
$router = SymfonyContainer::getInstance()->get('router');
|
||||
|
||||
return Tools::getHttpHost(true) . $router->generate('admin_module_manage_action', [
|
||||
'action' => 'install',
|
||||
'module_name' => $module,
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->link->getAdminLink('AdminModules', true, [], [
|
||||
'module_name' => $psxName,
|
||||
'configure' => $psxName,
|
||||
'install' => $module,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $module
|
||||
* @param string $psxName
|
||||
*
|
||||
* @return string | null
|
||||
*
|
||||
* @throws \PrestaShopException
|
||||
*/
|
||||
public function getEnableUrl($module, $psxName)
|
||||
{
|
||||
if ($this->shopContext->isShop17()) {
|
||||
$router = SymfonyContainer::getInstance()->get('router');
|
||||
|
||||
return Tools::getHttpHost(true) . $router->generate('admin_module_manage_action', [
|
||||
'action' => 'enable',
|
||||
'module_name' => $module,
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->link->getAdminLink('AdminModules', true, [], [
|
||||
'module_name' => $psxName,
|
||||
'configure' => $psxName,
|
||||
//'enable' => $module,
|
||||
'install' => $module,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $module
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isInstalled($module)
|
||||
{
|
||||
if (false === $this->shopContext->isShop17()) {
|
||||
return Module::isInstalled('ps_eventbus');
|
||||
}
|
||||
$moduleManager = ModuleManagerBuilder::getInstance()->build();
|
||||
|
||||
return $moduleManager->isInstalled($module);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $module
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEnabled($module)
|
||||
{
|
||||
if (false === $this->shopContext->isShop17()) {
|
||||
return Module::isEnabled($module);
|
||||
}
|
||||
$moduleManager = ModuleManagerBuilder::getInstance()->build();
|
||||
|
||||
return $moduleManager->isEnabled($module);
|
||||
}
|
||||
}
|
||||
113
modules/ps_accounts/classes/Module/Install.php
Normal file
113
modules/ps_accounts/classes/Module/Install.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Module;
|
||||
|
||||
use Tools;
|
||||
|
||||
class Install
|
||||
{
|
||||
const PARENT_TAB_NAME = -1;
|
||||
const TAB_ACTIVE = 0;
|
||||
|
||||
/**
|
||||
* @var \Ps_accounts
|
||||
*/
|
||||
private $module;
|
||||
|
||||
/**
|
||||
* @var \Db
|
||||
*/
|
||||
private $db;
|
||||
|
||||
public function __construct(\Ps_accounts $module, \Db $db)
|
||||
{
|
||||
$this->module = $module;
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* installInMenu.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws \PrestaShopDatabaseException
|
||||
* @throws \PrestaShopException
|
||||
*/
|
||||
public function installInMenu()
|
||||
{
|
||||
foreach ($this->module->adminControllers as $controllerName) {
|
||||
$tabId = (int) \Tab::getIdFromClassName($controllerName);
|
||||
|
||||
if (!$tabId) {
|
||||
$tabId = null;
|
||||
}
|
||||
|
||||
$tab = new \Tab($tabId);
|
||||
$tab->active = (bool) self::TAB_ACTIVE;
|
||||
$tab->class_name = $controllerName;
|
||||
$tab->name = [];
|
||||
|
||||
foreach (\Language::getLanguages(true) as $lang) {
|
||||
$tab->name[$lang['id_lang']] = $this->module->displayName;
|
||||
}
|
||||
|
||||
$tab->id_parent = -1 == self::PARENT_TAB_NAME ? (int) \Tab::getIdFromClassName((string) self::PARENT_TAB_NAME) : -1;
|
||||
$tab->module = $this->module->name;
|
||||
|
||||
$tab->save();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs database tables
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function installDatabaseTables()
|
||||
{
|
||||
$dbInstallFile = "{$this->module->getLocalPath()}/sql/install.sql";
|
||||
|
||||
if (!file_exists($dbInstallFile)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = Tools::file_get_contents($dbInstallFile);
|
||||
|
||||
if (empty($sql) || !is_string($sql)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = str_replace(['PREFIX_', 'ENGINE_TYPE'], [_DB_PREFIX_, _MYSQL_ENGINE_], $sql);
|
||||
$sql = preg_split("/;\s*[\r\n]+/", trim($sql));
|
||||
|
||||
if (!empty($sql)) {
|
||||
foreach ($sql as $query) {
|
||||
if (!$this->db->execute($query)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
95
modules/ps_accounts/classes/Module/Uninstall.php
Normal file
95
modules/ps_accounts/classes/Module/Uninstall.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Module;
|
||||
|
||||
use Tools;
|
||||
|
||||
class Uninstall
|
||||
{
|
||||
/**
|
||||
* @var \Ps_accounts
|
||||
*/
|
||||
private $module;
|
||||
/**
|
||||
* @var \Db
|
||||
*/
|
||||
private $db;
|
||||
|
||||
public function __construct(\Ps_accounts $module, \Db $db)
|
||||
{
|
||||
$this->module = $module;
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* uninstallMenu.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function uninstallMenu()
|
||||
{
|
||||
// foreach( ['configure', 'hmac', 'ajax'] as $aliasController){
|
||||
foreach ($this->module->adminControllers as $controllerName) {
|
||||
$tabId = (int) \Tab::getIdFromClassName($controllerName);
|
||||
|
||||
if (!$tabId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$tab = new \Tab($tabId);
|
||||
|
||||
return $tab->delete();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function uninstallDatabaseTables()
|
||||
{
|
||||
$dbUninstallFile = "{$this->module->getLocalPath()}/sql/uninstall.sql";
|
||||
|
||||
if (!file_exists($dbUninstallFile)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = Tools::file_get_contents($dbUninstallFile);
|
||||
|
||||
if (empty($sql) || !is_string($sql)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = str_replace(['PREFIX_', 'ENGINE_TYPE'], [_DB_PREFIX_, _MYSQL_ENGINE_], $sql);
|
||||
$sql = preg_split("/;\s*[\r\n]+/", trim($sql));
|
||||
|
||||
if (!empty($sql)) {
|
||||
foreach ($sql as $query) {
|
||||
if (!$this->db->execute($query)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
28
modules/ps_accounts/classes/Module/index.php
Normal file
28
modules/ps_accounts/classes/Module/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Presenter;
|
||||
|
||||
use Module;
|
||||
use PrestaShop\Module\PsAccounts\Installer\Installer;
|
||||
use Ps_accounts;
|
||||
|
||||
class DependenciesPresenter implements PresenterInterface
|
||||
{
|
||||
/**
|
||||
* @var Installer
|
||||
*/
|
||||
private $installer;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
/** @var Ps_accounts $psAccounts */
|
||||
$psAccounts = Module::getInstanceByName('ps_accounts');
|
||||
|
||||
$this->installer = $psAccounts->getService(Installer::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $psxName
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \PrestaShopException
|
||||
*/
|
||||
public function present($psxName = 'ps_accounts')
|
||||
{
|
||||
$module = 'ps_eventbus';
|
||||
|
||||
return [
|
||||
'dependencies' => [
|
||||
$module => [
|
||||
'isInstalled' => $this->installer->isInstalled($module),
|
||||
'installLink' => $this->installer->getInstallUrl($module, $psxName),
|
||||
|
||||
'isEnabled' => $this->installer->isEnabled($module),
|
||||
'enableLink' => $this->installer->getEnableUrl($module, $psxName),
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
34
modules/ps_accounts/classes/Presenter/PresenterInterface.php
Normal file
34
modules/ps_accounts/classes/Presenter/PresenterInterface.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Presenter;
|
||||
|
||||
/**
|
||||
* Interface StorePresenter defines methods for store presenter.
|
||||
*/
|
||||
interface PresenterInterface
|
||||
{
|
||||
/**
|
||||
* Present store
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function present();
|
||||
}
|
||||
161
modules/ps_accounts/classes/Presenter/PsAccountsPresenter.php
Normal file
161
modules/ps_accounts/classes/Presenter/PsAccountsPresenter.php
Normal file
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Presenter;
|
||||
|
||||
use Module;
|
||||
use PrestaShop\Module\PsAccounts\Handler\Error\Sentry;
|
||||
use PrestaShop\Module\PsAccounts\Installer\Installer;
|
||||
use PrestaShop\Module\PsAccounts\Provider\ShopProvider;
|
||||
use PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository;
|
||||
use PrestaShop\Module\PsAccounts\Service\PsAccountsService;
|
||||
use PrestaShop\Module\PsAccounts\Service\ShopLinkAccountService;
|
||||
use PrestaShop\Module\PsAccounts\Service\SsoService;
|
||||
|
||||
/**
|
||||
* Construct the psaccounts module.
|
||||
*/
|
||||
class PsAccountsPresenter implements PresenterInterface
|
||||
{
|
||||
/**
|
||||
* @var ShopProvider
|
||||
*/
|
||||
protected $shopProvider;
|
||||
|
||||
/**
|
||||
* @var ShopLinkAccountService
|
||||
*/
|
||||
protected $shopLinkAccountService;
|
||||
|
||||
/**
|
||||
* @var SsoService
|
||||
*/
|
||||
protected $ssoService;
|
||||
|
||||
/**
|
||||
* @var ConfigurationRepository
|
||||
*/
|
||||
protected $configuration;
|
||||
|
||||
/**
|
||||
* @var Installer
|
||||
*/
|
||||
private $installer;
|
||||
|
||||
/**
|
||||
* @var PsAccountsService
|
||||
*/
|
||||
private $psAccountsService;
|
||||
|
||||
/**
|
||||
* PsAccountsPresenter constructor.
|
||||
*
|
||||
* @param PsAccountsService $psAccountsService
|
||||
* @param ShopProvider $shopProvider
|
||||
* @param ShopLinkAccountService $shopLinkAccountService
|
||||
* @param SsoService $ssoService
|
||||
* @param Installer $installer
|
||||
* @param ConfigurationRepository $configuration
|
||||
*/
|
||||
public function __construct(
|
||||
PsAccountsService $psAccountsService,
|
||||
ShopProvider $shopProvider,
|
||||
ShopLinkAccountService $shopLinkAccountService,
|
||||
SsoService $ssoService,
|
||||
Installer $installer,
|
||||
ConfigurationRepository $configuration
|
||||
) {
|
||||
$this->psAccountsService = $psAccountsService;
|
||||
$this->shopProvider = $shopProvider;
|
||||
$this->shopLinkAccountService = $shopLinkAccountService;
|
||||
$this->ssoService = $ssoService;
|
||||
$this->installer = $installer;
|
||||
$this->configuration = $configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Present the PsAccounts module data for JS
|
||||
*
|
||||
* @param string $psxName
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function present($psxName = 'ps_accounts')
|
||||
{
|
||||
// FIXME : Do this elsewhere
|
||||
$this->shopLinkAccountService->manageOnboarding($psxName);
|
||||
|
||||
$shopContext = $this->shopProvider->getShopContext();
|
||||
|
||||
$isEnabled = $this->installer->isEnabled('ps_accounts');
|
||||
|
||||
try {
|
||||
return array_merge(
|
||||
[
|
||||
'psxName' => $psxName,
|
||||
'psIs17' => $shopContext->isShop17(),
|
||||
|
||||
/////////////////////////////
|
||||
// InstallerPresenter
|
||||
|
||||
'psAccountsIsInstalled' => true,
|
||||
'psAccountsInstallLink' => null,
|
||||
|
||||
'psAccountsIsEnabled' => true,
|
||||
'psAccountsEnableLink' => null,
|
||||
|
||||
'psAccountsIsUptodate' => true,
|
||||
'psAccountsUpdateLink' => null,
|
||||
|
||||
////////////////////////////
|
||||
// PsAccountsPresenter
|
||||
|
||||
'onboardingLink' => $this->shopLinkAccountService->getLinkAccountUrl($psxName),
|
||||
|
||||
// FIXME : Mix "SSO user" with "Backend user"
|
||||
'user' => [
|
||||
'email' => $this->configuration->getFirebaseEmail() ?: null,
|
||||
'emailIsValidated' => $this->configuration->firebaseEmailIsVerified(),
|
||||
'isSuperAdmin' => $shopContext->getContext()->employee->isSuperAdmin(),
|
||||
],
|
||||
|
||||
'currentShop' => $this->shopProvider->getCurrentShop($psxName),
|
||||
'isShopContext' => $shopContext->isShopContext(),
|
||||
'shops' => $this->shopProvider->getShopsTree($psxName),
|
||||
|
||||
'superAdminEmail' => $this->psAccountsService->getSuperAdminEmail(),
|
||||
|
||||
// FIXME : move into Vue components .env
|
||||
'ssoResendVerificationEmail' => $this->ssoService->getSsoResendVerificationEmailUrl(),
|
||||
'manageAccountLink' => $this->ssoService->getSsoAccountUrl(),
|
||||
|
||||
'adminAjaxLink' => $this->psAccountsService->getAdminAjaxUrl(),
|
||||
],
|
||||
(new DependenciesPresenter())->present($psxName)
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
Sentry::captureAndRethrow($e);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Presenter\Store\Context;
|
||||
|
||||
use Context;
|
||||
use PrestaShop\Module\PsAccounts\Adapter\Link;
|
||||
use PrestaShop\Module\PsAccounts\Presenter\PresenterInterface;
|
||||
use PrestaShop\Module\PsAccounts\Provider\ShopProvider;
|
||||
use PrestaShop\Module\PsAccounts\Service\PsAccountsService;
|
||||
use Ps_accounts;
|
||||
|
||||
class ContextPresenter implements PresenterInterface
|
||||
{
|
||||
/**
|
||||
* @var Ps_accounts
|
||||
*/
|
||||
private $module;
|
||||
|
||||
/**
|
||||
* @var PsAccountsService
|
||||
*/
|
||||
private $psAccountsService;
|
||||
|
||||
/**
|
||||
* @var Context
|
||||
*/
|
||||
private $context;
|
||||
|
||||
public function __construct(Ps_accounts $module, Context $context)
|
||||
{
|
||||
$this->module = $module;
|
||||
$this->context = $context;
|
||||
$this->psAccountsService = $this->module->getService(PsAccountsService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the merchant is onboarded on ps accounts
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function psAccountsIsOnboarded()
|
||||
{
|
||||
if ($this->psAccountsService->getRefreshToken() && $this->psAccountsService->isEmailValidated()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Present the Context Vuex
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \PrestaShopException
|
||||
*/
|
||||
public function present()
|
||||
{
|
||||
/** @var Link $linkAdapter */
|
||||
$linkAdapter = $this->module->getService(Link::class);
|
||||
|
||||
/** @var ShopProvider $shopProvider */
|
||||
$shopProvider = $this->module->getService(ShopProvider::class);
|
||||
|
||||
$currentShop = $shopProvider->getCurrentShop();
|
||||
|
||||
return [
|
||||
'context' => [
|
||||
'app' => $this->getCurrentVueApp(),
|
||||
'user' => [
|
||||
'psAccountsIsOnboarded' => $this->psAccountsIsOnboarded(),
|
||||
],
|
||||
'version_ps' => _PS_VERSION_,
|
||||
'version_module' => $this->module->version,
|
||||
'shopId' => $this->psAccountsService->getShopUuidV4(),
|
||||
'isShop17' => version_compare(_PS_VERSION_, '1.7.3.0', '>='),
|
||||
'configurationLink' => $linkAdapter->getAdminLink('AdminModules', true, [], ['configure' => $this->module->name]),
|
||||
'controllersLinks' => [
|
||||
'ajax' => $linkAdapter->getAdminLink('AdminAjaxPsAccounts'),
|
||||
],
|
||||
'i18n' => [
|
||||
'isoCode' => $this->context->language->iso_code,
|
||||
'languageLocale' => $this->context->language->language_code,
|
||||
'currencyIsoCode' => $this->context->currency->iso_code,
|
||||
],
|
||||
'shop' => [
|
||||
'domain' => $currentShop['domain'],
|
||||
'url' => $currentShop['url'],
|
||||
],
|
||||
'readmeUrl' => $this->getReadme(),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Vue App to use in terms of context Controller Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getCurrentVueApp()
|
||||
{
|
||||
return 'settings';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the documentation url depending on the current language
|
||||
*
|
||||
* @return string path of the doc
|
||||
*/
|
||||
private function getReadme()
|
||||
{
|
||||
$isoCode = $this->context->language->iso_code;
|
||||
|
||||
if (!file_exists(_PS_ROOT_DIR_ . _MODULE_DIR_ . $this->module->name . '/docs/readme_' . $isoCode . '.pdf')) {
|
||||
$isoCode = 'en';
|
||||
}
|
||||
|
||||
return _MODULE_DIR_ . $this->module->name . '/docs/readme_' . $isoCode . '.pdf';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Presenter\Store;
|
||||
|
||||
use Context;
|
||||
use PrestaShop\Module\PsAccounts\Presenter\PresenterInterface;
|
||||
use PrestaShop\Module\PsAccounts\Presenter\Store\Context\ContextPresenter;
|
||||
use PrestaShop\Module\PsAccounts\Translations\SettingsTranslations;
|
||||
|
||||
/**
|
||||
* Present the store to the vuejs app (vuex)
|
||||
*/
|
||||
class StorePresenter implements PresenterInterface
|
||||
{
|
||||
/**
|
||||
* @var \Ps_accounts
|
||||
*/
|
||||
private $module;
|
||||
|
||||
/**
|
||||
* @var Context
|
||||
*/
|
||||
private $context;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $store;
|
||||
|
||||
/**
|
||||
* @param \Ps_accounts $module
|
||||
* @param Context $context
|
||||
* @param array|null $store
|
||||
*/
|
||||
public function __construct(\Ps_accounts $module, Context $context, array $store = null)
|
||||
{
|
||||
// Allow to set a custom store for tests purpose
|
||||
if (null !== $store) {
|
||||
$this->store = $store;
|
||||
}
|
||||
|
||||
$this->module = $module;
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the store required by vuex
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \PrestaShopException
|
||||
*/
|
||||
public function present()
|
||||
{
|
||||
if (null !== $this->store) {
|
||||
return $this->store;
|
||||
}
|
||||
|
||||
$contextPresenter = (new ContextPresenter($this->module, $this->context))->present();
|
||||
|
||||
// Load a presenter depending on the application to load (dashboard | settings)
|
||||
$this->store = array_merge(
|
||||
$contextPresenter,
|
||||
[
|
||||
'settings' => [
|
||||
'faq' => false,
|
||||
'translations' => (new SettingsTranslations($this->module))->getTranslations(),
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
return $this->store;
|
||||
}
|
||||
}
|
||||
28
modules/ps_accounts/classes/Presenter/Store/index.php
Normal file
28
modules/ps_accounts/classes/Presenter/Store/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
28
modules/ps_accounts/classes/Presenter/index.php
Normal file
28
modules/ps_accounts/classes/Presenter/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
132
modules/ps_accounts/classes/Provider/ShopProvider.php
Normal file
132
modules/ps_accounts/classes/Provider/ShopProvider.php
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Provider;
|
||||
|
||||
use PrestaShop\Module\PsAccounts\Adapter\Link;
|
||||
use PrestaShop\Module\PsAccounts\Context\ShopContext;
|
||||
|
||||
class ShopProvider
|
||||
{
|
||||
/**
|
||||
* @var ShopContext
|
||||
*/
|
||||
private $shopContext;
|
||||
|
||||
/**
|
||||
* @var Link
|
||||
*/
|
||||
private $link;
|
||||
|
||||
/**
|
||||
* ShopProvider constructor.
|
||||
*
|
||||
* @param ShopContext $shopContext
|
||||
* @param Link $link
|
||||
*/
|
||||
public function __construct(
|
||||
ShopContext $shopContext,
|
||||
Link $link
|
||||
) {
|
||||
$this->shopContext = $shopContext;
|
||||
$this->link = $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $psxName
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \PrestaShopException
|
||||
*/
|
||||
public function getCurrentShop($psxName = '')
|
||||
{
|
||||
$shop = \Shop::getShop($this->shopContext->getContext()->shop->id);
|
||||
|
||||
return [
|
||||
'id' => $shop['id_shop'],
|
||||
'name' => $shop['name'],
|
||||
'domain' => $shop['domain'],
|
||||
'domainSsl' => $shop['domain_ssl'],
|
||||
'url' => $this->link->getAdminLink(
|
||||
'AdminModules',
|
||||
true,
|
||||
[],
|
||||
[
|
||||
'configure' => $psxName,
|
||||
'setShopContext' => 's-' . $shop['id_shop'],
|
||||
]
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $psxName
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \PrestaShopException
|
||||
*/
|
||||
public function getShopsTree($psxName)
|
||||
{
|
||||
$shopList = [];
|
||||
|
||||
if (true === $this->shopContext->isShopContext()) {
|
||||
return $shopList;
|
||||
}
|
||||
|
||||
foreach (\Shop::getTree() as $groupId => $groupData) {
|
||||
$shops = [];
|
||||
foreach ($groupData['shops'] as $shopId => $shopData) {
|
||||
$shops[] = [
|
||||
'id' => $shopId,
|
||||
'name' => $shopData['name'],
|
||||
'domain' => $shopData['domain'],
|
||||
'domainSsl' => $shopData['domain_ssl'],
|
||||
'url' => $this->link->getAdminLink(
|
||||
'AdminModules',
|
||||
true,
|
||||
[],
|
||||
[
|
||||
'configure' => $psxName,
|
||||
'setShopContext' => 's-' . $shopId,
|
||||
]
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
$shopList[] = [
|
||||
'id' => $groupId,
|
||||
'name' => $groupData['name'],
|
||||
'shops' => $shops,
|
||||
];
|
||||
}
|
||||
|
||||
return $shopList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ShopContext
|
||||
*/
|
||||
public function getShopContext()
|
||||
{
|
||||
return $this->shopContext;
|
||||
}
|
||||
}
|
||||
28
modules/ps_accounts/classes/Provider/index.php
Normal file
28
modules/ps_accounts/classes/Provider/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@@ -0,0 +1,256 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Repository;
|
||||
|
||||
use PrestaShop\Module\PsAccounts\Adapter\Configuration;
|
||||
|
||||
class ConfigurationRepository
|
||||
{
|
||||
/**
|
||||
* @var Configuration
|
||||
*/
|
||||
private $configuration;
|
||||
|
||||
/**
|
||||
* ConfigurationRepository constructor.
|
||||
*
|
||||
* @param Configuration|null $configuration
|
||||
*/
|
||||
public function __construct(Configuration $configuration = null)
|
||||
{
|
||||
$this->configuration = $configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getShopId()
|
||||
{
|
||||
return $this->configuration->getIdShop();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $shopId
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setShopId($shopId)
|
||||
{
|
||||
$this->configuration->setIdShop($shopId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFirebaseIdToken()
|
||||
{
|
||||
return $this->configuration->get(Configuration::PS_ACCOUNTS_FIREBASE_ID_TOKEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFirebaseRefreshToken()
|
||||
{
|
||||
return $this->configuration->get(Configuration::PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $idToken
|
||||
* @param string $refreshToken
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function updateFirebaseIdAndRefreshTokens($idToken, $refreshToken)
|
||||
{
|
||||
if (false === $this->configuration->get(Configuration::PS_PSX_FIREBASE_ID_TOKEN)) {
|
||||
// FIXME: This to avoid mutual disconnect between ps_accounts & ps_checkout
|
||||
$this->configuration->set(Configuration::PS_PSX_FIREBASE_ID_TOKEN, $idToken);
|
||||
$this->configuration->set(Configuration::PS_PSX_FIREBASE_REFRESH_TOKEN, $refreshToken);
|
||||
$this->configuration->set(Configuration::PS_PSX_FIREBASE_REFRESH_DATE, date('Y-m-d H:i:s'));
|
||||
}
|
||||
$this->configuration->set(Configuration::PS_ACCOUNTS_FIREBASE_ID_TOKEN, $idToken);
|
||||
$this->configuration->set(Configuration::PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN, $refreshToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we have a refresh token.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasFirebaseRefreshToken()
|
||||
{
|
||||
return !empty($this->configuration->get(Configuration::PS_ACCOUNTS_FIREBASE_REFRESH_TOKEN));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string | null
|
||||
*/
|
||||
public function getFirebaseEmail()
|
||||
{
|
||||
return $this->configuration->get(Configuration::PS_ACCOUNTS_FIREBASE_EMAIL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $email
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function updateFirebaseEmail($email)
|
||||
{
|
||||
if (false === $this->configuration->get(Configuration::PS_PSX_FIREBASE_EMAIL)) {
|
||||
$this->configuration->set(Configuration::PS_PSX_FIREBASE_EMAIL, $email);
|
||||
}
|
||||
$this->configuration->set(Configuration::PS_ACCOUNTS_FIREBASE_EMAIL, $email);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function firebaseEmailIsVerified()
|
||||
{
|
||||
return in_array(
|
||||
$this->configuration->get(Configuration::PS_ACCOUNTS_FIREBASE_EMAIL_IS_VERIFIED),
|
||||
['1', 1, true]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $status
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function updateFirebaseEmailIsVerified($status)
|
||||
{
|
||||
$this->configuration->set(
|
||||
Configuration::PS_ACCOUNTS_FIREBASE_EMAIL_IS_VERIFIED,
|
||||
(string) $status
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since v4.0.0
|
||||
*
|
||||
* @return string | null
|
||||
*/
|
||||
public function getFirebaseLocalId()
|
||||
{
|
||||
return $this->configuration->get(Configuration::PS_ACCOUNTS_FIREBASE_LOCAL_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated sibce v4.0.0
|
||||
*
|
||||
* @param string $localId
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function updateFirebaseLocalId($localId)
|
||||
{
|
||||
if (false === $this->configuration->get(Configuration::PS_PSX_FIREBASE_LOCAL_ID)) {
|
||||
$this->configuration->set(Configuration::PS_PSX_FIREBASE_LOCAL_ID, $localId);
|
||||
}
|
||||
$this->configuration->set(Configuration::PS_ACCOUNTS_FIREBASE_LOCAL_ID, $localId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getShopUuid()
|
||||
{
|
||||
return $this->configuration->get(Configuration::PSX_UUID_V4);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $uuid Firebase User UUID
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function updateShopUuid($uuid)
|
||||
{
|
||||
if (false === $this->configuration->get(Configuration::PS_CHECKOUT_SHOP_UUID_V4)) {
|
||||
$this->configuration->set(Configuration::PS_CHECKOUT_SHOP_UUID_V4, $uuid);
|
||||
}
|
||||
$this->configuration->set(Configuration::PSX_UUID_V4, $uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAccountsRsaPrivateKey()
|
||||
{
|
||||
return $this->configuration->get(Configuration::PS_ACCOUNTS_RSA_PRIVATE_KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function updateAccountsRsaPrivateKey($key)
|
||||
{
|
||||
$this->configuration->set(Configuration::PS_ACCOUNTS_RSA_PRIVATE_KEY, $key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAccountsRsaPublicKey()
|
||||
{
|
||||
return $this->configuration->get(Configuration::PS_ACCOUNTS_RSA_PUBLIC_KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function updateAccountsRsaPublicKey($key)
|
||||
{
|
||||
$this->configuration->set(Configuration::PS_ACCOUNTS_RSA_PUBLIC_KEY, $key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAccountsRsaSignData()
|
||||
{
|
||||
return $this->configuration->get(Configuration::PS_ACCOUNTS_RSA_SIGN_DATA);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $signData
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function updateAccountsRsaSignData($signData)
|
||||
{
|
||||
$this->configuration->set(Configuration::PS_ACCOUNTS_RSA_SIGN_DATA, $signData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function sslEnabled()
|
||||
{
|
||||
return true == $this->configuration->get('PS_SSL_ENABLED');
|
||||
}
|
||||
}
|
||||
57
modules/ps_accounts/classes/Repository/ShopRepository.php
Normal file
57
modules/ps_accounts/classes/Repository/ShopRepository.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Repository;
|
||||
|
||||
use Context;
|
||||
use Db;
|
||||
use DbQuery;
|
||||
|
||||
class ShopRepository
|
||||
{
|
||||
/**
|
||||
* @var Context
|
||||
*/
|
||||
private $context;
|
||||
/**
|
||||
* @var Db
|
||||
*/
|
||||
private $db;
|
||||
|
||||
public function __construct(Context $context, Db $db)
|
||||
{
|
||||
$this->context = $context;
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMultiShopCount()
|
||||
{
|
||||
$query = new DbQuery();
|
||||
|
||||
$query->select('COUNT(id_shop)')
|
||||
->from('shop')
|
||||
->where('active = 1 and deleted = 0');
|
||||
|
||||
return (int) $this->db->getValue($query);
|
||||
}
|
||||
}
|
||||
28
modules/ps_accounts/classes/Repository/index.php
Normal file
28
modules/ps_accounts/classes/Repository/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
159
modules/ps_accounts/classes/Service/PsAccountsService.php
Normal file
159
modules/ps_accounts/classes/Service/PsAccountsService.php
Normal file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Service;
|
||||
|
||||
use PrestaShop\Module\PsAccounts\Adapter\Link;
|
||||
use PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository;
|
||||
|
||||
/**
|
||||
* Class PsAccountsService
|
||||
*/
|
||||
class PsAccountsService
|
||||
{
|
||||
/**
|
||||
* @var Link
|
||||
*/
|
||||
protected $link;
|
||||
|
||||
/**
|
||||
* @var ConfigurationRepository
|
||||
*/
|
||||
private $configuration;
|
||||
|
||||
/**
|
||||
* @var \Ps_accounts
|
||||
*/
|
||||
private $module;
|
||||
|
||||
/**
|
||||
* @var ShopTokenService
|
||||
*/
|
||||
private $shopTokenService;
|
||||
|
||||
/**
|
||||
* PsAccountsService constructor.
|
||||
*
|
||||
* @param \Ps_accounts $module
|
||||
* @param ShopTokenService $shopTokenService
|
||||
* @param ConfigurationRepository $configuration
|
||||
* @param Link $link
|
||||
*/
|
||||
public function __construct(
|
||||
\Ps_accounts $module,
|
||||
ShopTokenService $shopTokenService,
|
||||
ConfigurationRepository $configuration,
|
||||
Link $link
|
||||
) {
|
||||
$this->configuration = $configuration;
|
||||
$this->shopTokenService = $shopTokenService;
|
||||
$this->module = $module;
|
||||
$this->link = $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSuperAdminEmail()
|
||||
{
|
||||
return (new \Employee(1))->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string | false
|
||||
*/
|
||||
public function getShopUuidV4()
|
||||
{
|
||||
return $this->configuration->getShopUuid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user firebase token.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getOrRefreshToken()
|
||||
{
|
||||
return $this->shopTokenService->getOrRefreshToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getRefreshToken()
|
||||
{
|
||||
return $this->shopTokenService->getRefreshToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getToken()
|
||||
{
|
||||
return $this->shopTokenService->getToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmailValidated()
|
||||
{
|
||||
return $this->configuration->firebaseEmailIsVerified();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getEmail()
|
||||
{
|
||||
return $this->configuration->getFirebaseEmail();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function isAccountLinked()
|
||||
{
|
||||
/** @var ShopLinkAccountService $shopLinkAccountService */
|
||||
$shopLinkAccountService = $this->module->getService(ShopLinkAccountService::class);
|
||||
|
||||
return $shopLinkAccountService->isAccountLinked();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate ajax admin link with token
|
||||
* available via PsAccountsPresenter into page dom,
|
||||
* ex :
|
||||
* let url = window.contextPsAccounts.adminAjaxLink + '&action=unlinkShop'
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \PrestaShopException
|
||||
*/
|
||||
public function getAdminAjaxUrl()
|
||||
{
|
||||
// Tools::getAdminTokenLite('AdminAjaxPsAccounts'));
|
||||
return $this->link->getAdminLink('AdminAjaxPsAccounts', true, [], ['ajax' => 1]);
|
||||
}
|
||||
}
|
||||
168
modules/ps_accounts/classes/Service/PsBillingService.php
Normal file
168
modules/ps_accounts/classes/Service/PsBillingService.php
Normal file
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Service;
|
||||
|
||||
use Context;
|
||||
use PrestaShop\Module\PsAccounts\Api\Client\ServicesBillingClient;
|
||||
use PrestaShop\Module\PsAccounts\Exception\BillingException;
|
||||
use PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository;
|
||||
|
||||
/**
|
||||
* Construct the psbilling service.
|
||||
*/
|
||||
class PsBillingService
|
||||
{
|
||||
// /**
|
||||
// * @var \Symfony\Component\DependencyInjection\ContainerInterface
|
||||
// */
|
||||
// protected $container;
|
||||
|
||||
/**
|
||||
* @var ConfigurationRepository
|
||||
*/
|
||||
private $configuration;
|
||||
|
||||
/**
|
||||
* @var ShopTokenService
|
||||
*/
|
||||
private $shopTokenService;
|
||||
|
||||
/**
|
||||
* @var ServicesBillingClient
|
||||
*/
|
||||
private $servicesBillingClient;
|
||||
|
||||
/**
|
||||
* PsBillingService constructor.
|
||||
*
|
||||
* @param ServicesBillingClient $servicesBillingClient
|
||||
* @param ShopTokenService $shopTokenService
|
||||
* @param ConfigurationRepository $configuration
|
||||
*/
|
||||
public function __construct(
|
||||
ServicesBillingClient $servicesBillingClient,
|
||||
ShopTokenService $shopTokenService,
|
||||
ConfigurationRepository $configuration
|
||||
) {
|
||||
$this->servicesBillingClient = $servicesBillingClient;
|
||||
$this->shopTokenService = $shopTokenService;
|
||||
$this->configuration = $configuration;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Override of native function to always retrieve Symfony container instead of legacy admin container on legacy context.
|
||||
// *
|
||||
// * @param string $serviceName
|
||||
// *
|
||||
// * @return mixed
|
||||
// */
|
||||
// public function get($serviceName)
|
||||
// {
|
||||
// if (null === $this->container) {
|
||||
// $this->container = \PrestaShop\PrestaShop\Adapter\SymfonyContainer::getInstance();
|
||||
// }
|
||||
//
|
||||
// return $this->container->get($serviceName);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Create a Billing customer if needed, and subscribe to $planName.
|
||||
* The $module and $planName must exist in PrestaShop Billing.
|
||||
* The $ip parameter will help PS Billing to preselect a tax rate and a currency
|
||||
* from the geolocalized IP. This IP should be the browser IP displaying the backoffice.
|
||||
*
|
||||
* @param string $module the name of the module
|
||||
* @param string $planName The label of the existing plan for this module
|
||||
* @param mixed $shopId an optional shop ID in multishop context. If left false, the current shop will be selected.
|
||||
* @param mixed $customerIp an optional element to help Billing choosing the currency and tax rate (depending on the IP's country) for later paying plan
|
||||
*
|
||||
* @return mixed An array with subscription identifiers if succeed
|
||||
*
|
||||
* @throws \Exception in case of error
|
||||
*/
|
||||
public function subscribeToFreePlan($module, $planName, $shopId = false, $customerIp = null)
|
||||
{
|
||||
if ($shopId !== false) {
|
||||
$this->configuration->setShopId($shopId);
|
||||
}
|
||||
|
||||
$uuid = $this->configuration->getShopUuid();
|
||||
$toReturn = ['shopAccountId' => $uuid];
|
||||
|
||||
if ($uuid && strlen($uuid) > 0) {
|
||||
$billingClient = $this->servicesBillingClient;
|
||||
|
||||
$response = $billingClient->getBillingCustomer($uuid);
|
||||
|
||||
if (!$response || !array_key_exists('httpCode', $response)) {
|
||||
throw new BillingException('Billing customer request failed.', 50);
|
||||
}
|
||||
if ($response['httpCode'] === 404) {
|
||||
$response = $billingClient->createBillingCustomer(
|
||||
$uuid,
|
||||
$customerIp ? ['created_from_ip' => $customerIp] : []
|
||||
);
|
||||
if (!$response || !array_key_exists('httpCode', $response) || $response['httpCode'] !== 201) {
|
||||
throw new BillingException('Billing customer creation failed.', 60);
|
||||
}
|
||||
}
|
||||
$toReturn['customerId'] = $response['body']['customer']['id'];
|
||||
|
||||
$response = $billingClient->getBillingSubscriptions($uuid, $module);
|
||||
if (!$response || !array_key_exists('httpCode', $response) || $response['httpCode'] >= 500) {
|
||||
throw new BillingException('Billing subscriptions request failed.', 51);
|
||||
}
|
||||
|
||||
if ($response['httpCode'] === 404) {
|
||||
$response = $billingClient->createBillingSubscriptions($uuid, $module, ['plan_id' => $planName, 'module' => $module]);
|
||||
if (!$response || !array_key_exists('httpCode', $response) || $response['httpCode'] >= 400) {
|
||||
if ($response && array_key_exists('body', $response)
|
||||
&& array_key_exists('message', $response['body'])
|
||||
&& array_key_exists(0, $response['body']['message'])
|
||||
) {
|
||||
throw new BillingException($response['body']['message'][0]);
|
||||
}
|
||||
throw new BillingException('Billing subscription creation failed.', 65);
|
||||
}
|
||||
|
||||
$toReturn['subscriptionId'] = $response['body']['subscription']['id'];
|
||||
|
||||
return $toReturn;
|
||||
} else {
|
||||
// There is existing subscription. Testing if planName matches the right one.
|
||||
if (array_key_exists('body', $response) && $response['body']
|
||||
&& array_key_exists('subscription', $response['body'])
|
||||
&& array_key_exists('plan_id', $response['body']['subscription'])
|
||||
&& $response['body']['subscription']['plan_id'] === $planName
|
||||
) {
|
||||
$toReturn['subscriptionId'] = $response['body']['subscription']['id'];
|
||||
$this->shopTokenService->getOrRefreshToken();
|
||||
|
||||
return $toReturn;
|
||||
} else {
|
||||
throw new BillingException('Subscription plan name mismatch.', 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new \Exception('Shop account unknown.', 10);
|
||||
}
|
||||
}
|
||||
155
modules/ps_accounts/classes/Service/ShopKeysService.php
Normal file
155
modules/ps_accounts/classes/Service/ShopKeysService.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Service;
|
||||
|
||||
use phpseclib\Crypt\RSA;
|
||||
use PrestaShop\Module\PsAccounts\Exception\SshKeysNotFoundException;
|
||||
use PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository;
|
||||
|
||||
/**
|
||||
* Manage RSA
|
||||
*/
|
||||
class ShopKeysService
|
||||
{
|
||||
const SIGNATURE_DATA = 'data';
|
||||
|
||||
/**
|
||||
* @var RSA
|
||||
*/
|
||||
private $rsa;
|
||||
|
||||
/**
|
||||
* @var ConfigurationRepository
|
||||
*/
|
||||
private $configuration;
|
||||
|
||||
public function __construct(ConfigurationRepository $configuration)
|
||||
{
|
||||
$this->rsa = new RSA();
|
||||
$this->rsa->setHash('sha256');
|
||||
$this->rsa->setSignatureMode(RSA::SIGNATURE_PKCS1);
|
||||
|
||||
$this->configuration = $configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function createPair()
|
||||
{
|
||||
$this->rsa->setPrivateKeyFormat(RSA::PRIVATE_FORMAT_PKCS1);
|
||||
$this->rsa->setPublicKeyFormat(RSA::PUBLIC_FORMAT_PKCS1);
|
||||
|
||||
return $this->rsa->createKey();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $privateKey
|
||||
* @param string $data
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function signData($privateKey, $data)
|
||||
{
|
||||
$this->rsa->loadKey($privateKey, RSA::PRIVATE_FORMAT_PKCS1);
|
||||
|
||||
return base64_encode($this->rsa->sign($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $publicKey
|
||||
* @param string $signature
|
||||
* @param string $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function verifySignature($publicKey, $signature, $data)
|
||||
{
|
||||
$this->rsa->loadKey($publicKey, RSA::PUBLIC_FORMAT_PKCS1);
|
||||
|
||||
return $this->rsa->verify($data, base64_decode($signature));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $refresh
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws SshKeysNotFoundException
|
||||
*/
|
||||
public function generateKeys($refresh = true)
|
||||
{
|
||||
if ($refresh || false === $this->hasKeys()) {
|
||||
$key = $this->createPair();
|
||||
$this->configuration->updateAccountsRsaPrivateKey($key['privatekey']);
|
||||
$this->configuration->updateAccountsRsaPublicKey($key['publickey']);
|
||||
|
||||
$this->configuration->updateAccountsRsaSignData(
|
||||
$this->signData(
|
||||
$this->configuration->getAccountsRsaPrivateKey(),
|
||||
self::SIGNATURE_DATA
|
||||
)
|
||||
);
|
||||
|
||||
if (false === $this->hasKeys()) {
|
||||
throw new SshKeysNotFoundException('No RSA keys found for the shop');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*
|
||||
* @throws SshKeysNotFoundException
|
||||
*/
|
||||
public function regenerateKeys()
|
||||
{
|
||||
$this->generateKeys(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasKeys()
|
||||
{
|
||||
return false === (
|
||||
empty($this->configuration->getAccountsRsaPublicKey())
|
||||
|| empty($this->configuration->getAccountsRsaPrivateKey())
|
||||
|| empty($this->configuration->getAccountsRsaSignData())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPublicKey()
|
||||
{
|
||||
return $this->configuration->getAccountsRsaPublicKey();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSignature()
|
||||
{
|
||||
return $this->configuration->getAccountsRsaSignData();
|
||||
}
|
||||
}
|
||||
388
modules/ps_accounts/classes/Service/ShopLinkAccountService.php
Normal file
388
modules/ps_accounts/classes/Service/ShopLinkAccountService.php
Normal file
@@ -0,0 +1,388 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Service;
|
||||
|
||||
use Module;
|
||||
use PrestaShop\Module\PsAccounts\Adapter\Link;
|
||||
use PrestaShop\Module\PsAccounts\Api\Client\ServicesAccountsClient;
|
||||
use PrestaShop\Module\PsAccounts\Configuration\ConfigOptionsResolver;
|
||||
use PrestaShop\Module\PsAccounts\Configuration\Configurable;
|
||||
use PrestaShop\Module\PsAccounts\Exception\HmacException;
|
||||
use PrestaShop\Module\PsAccounts\Exception\OptionResolutionException;
|
||||
use PrestaShop\Module\PsAccounts\Exception\QueryParamsException;
|
||||
use PrestaShop\Module\PsAccounts\Exception\RsaSignedDataNotFoundException;
|
||||
use PrestaShop\Module\PsAccounts\Exception\SshKeysNotFoundException;
|
||||
use PrestaShop\Module\PsAccounts\Provider\ShopProvider;
|
||||
use PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository;
|
||||
use Ps_accounts;
|
||||
|
||||
class ShopLinkAccountService implements Configurable
|
||||
{
|
||||
/**
|
||||
* @var ShopKeysService
|
||||
*/
|
||||
private $shopKeysService;
|
||||
|
||||
/**
|
||||
* @var ShopProvider
|
||||
*/
|
||||
private $shopProvider;
|
||||
|
||||
/**
|
||||
* @var ShopTokenService
|
||||
*/
|
||||
private $shopTokenService;
|
||||
|
||||
/**
|
||||
* @var ConfigurationRepository
|
||||
*/
|
||||
private $configuration;
|
||||
|
||||
/**
|
||||
* @var Link
|
||||
*/
|
||||
private $link;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $accountsUiUrl;
|
||||
|
||||
/**
|
||||
* ShopLinkAccountService constructor.
|
||||
*
|
||||
* @param array $config
|
||||
* @param ShopProvider $shopProvider
|
||||
* @param ShopKeysService $shopKeysService
|
||||
* @param ShopTokenService $shopTokenService
|
||||
* @param ConfigurationRepository $configuration
|
||||
* @param Link $link
|
||||
*
|
||||
* @throws OptionResolutionException
|
||||
*/
|
||||
public function __construct(
|
||||
array $config,
|
||||
ShopProvider $shopProvider,
|
||||
ShopKeysService $shopKeysService,
|
||||
ShopTokenService $shopTokenService,
|
||||
ConfigurationRepository $configuration,
|
||||
Link $link
|
||||
) {
|
||||
$this->accountsUiUrl = $this->resolveConfig($config)['accounts_ui_url'];
|
||||
$this->shopProvider = $shopProvider;
|
||||
$this->shopKeysService = $shopKeysService;
|
||||
$this->shopTokenService = $shopTokenService;
|
||||
$this->configuration = $configuration;
|
||||
$this->link = $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ServicesAccountsClient
|
||||
*/
|
||||
public function getServicesAccountsClient()
|
||||
{
|
||||
/** @var Ps_accounts $module */
|
||||
$module = Module::getInstanceByName('ps_accounts');
|
||||
|
||||
return $module->getService(ServicesAccountsClient::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $bodyHttp
|
||||
* @param string $trigger
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function updateShopUrl($bodyHttp, $trigger)
|
||||
{
|
||||
if (array_key_exists('shop_id', $bodyHttp)) {
|
||||
// id for multishop
|
||||
$this->configuration->setShopId($bodyHttp['shop_id']);
|
||||
}
|
||||
|
||||
$sslEnabled = $this->shopProvider->getShopContext()->sslEnabled();
|
||||
$protocol = $this->shopProvider->getShopContext()->getProtocol();
|
||||
$domain = $sslEnabled ? $bodyHttp['domain_ssl'] : $bodyHttp['domain'];
|
||||
|
||||
$uuid = $this->configuration->getShopUuid();
|
||||
|
||||
$response = false;
|
||||
$boUrl = $this->replaceScheme(
|
||||
$this->link->getAdminLink('AdminModules', true),
|
||||
$protocol . '://' . $domain
|
||||
);
|
||||
|
||||
if ($uuid && strlen($uuid) > 0) {
|
||||
$response = $this->getServicesAccountsClient()->updateShopUrl(
|
||||
$uuid,
|
||||
[
|
||||
'protocol' => $protocol,
|
||||
'domain' => $domain,
|
||||
'boUrl' => $boUrl,
|
||||
'trigger' => $trigger,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $psxName
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \PrestaShopException
|
||||
*/
|
||||
public function getLinkAccountUrl($psxName)
|
||||
{
|
||||
$callback = $this->replaceScheme(
|
||||
$this->link->getAdminLink('AdminModules', true) . '&configure=' . $psxName
|
||||
);
|
||||
|
||||
$protocol = $this->shopProvider->getShopContext()->getProtocol();
|
||||
$currentShop = $this->shopProvider->getCurrentShop($psxName);
|
||||
$domainName = $this->shopProvider->getShopContext()->sslEnabled() ? $currentShop['domainSsl'] : $currentShop['domain'];
|
||||
|
||||
$queryParams = [
|
||||
'bo' => $callback,
|
||||
'pubKey' => $this->shopKeysService->getPublicKey(),
|
||||
'next' => $this->replaceScheme(
|
||||
$this->link->getAdminLink('AdminConfigureHmacPsAccounts')
|
||||
),
|
||||
'name' => $currentShop['name'],
|
||||
'lang' => $this->shopProvider->getShopContext()->getContext()->language->iso_code,
|
||||
];
|
||||
|
||||
$queryParamsArray = [];
|
||||
foreach ($queryParams as $key => $value) {
|
||||
$queryParamsArray[] = $key . '=' . urlencode($value);
|
||||
}
|
||||
$strQueryParams = implode('&', $queryParamsArray);
|
||||
|
||||
return $this->accountsUiUrl . '/shop/account/link/' . $protocol . '/' . $domainName
|
||||
. '/' . $protocol . '/' . $domainName . '/' . $psxName . '?' . $strQueryParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $queryParams
|
||||
* @param string $rootDir
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws HmacException
|
||||
* @throws QueryParamsException
|
||||
* @throws RsaSignedDataNotFoundException
|
||||
*/
|
||||
public function getVerifyAccountUrl(array $queryParams, $rootDir)
|
||||
{
|
||||
foreach (
|
||||
[
|
||||
'hmac' => '/[a-zA-Z0-9]{8,64}/',
|
||||
'uid' => '/[a-zA-Z0-9]{8,64}/',
|
||||
'slug' => '/[-_a-zA-Z0-9]{8,255}/',
|
||||
] as $key => $value
|
||||
) {
|
||||
if (!array_key_exists($key, $queryParams)) {
|
||||
throw new QueryParamsException('Missing query params');
|
||||
}
|
||||
|
||||
if (!preg_match($value, $queryParams[$key])) {
|
||||
throw new QueryParamsException('Invalid query params');
|
||||
}
|
||||
}
|
||||
|
||||
$this->writeHmac($queryParams['hmac'], $queryParams['uid'], $rootDir . '/upload/');
|
||||
|
||||
if (empty($this->shopKeysService->getSignature())) {
|
||||
throw new RsaSignedDataNotFoundException('RSA signature not found');
|
||||
}
|
||||
|
||||
$url = $this->accountsUiUrl;
|
||||
|
||||
if ('/' === substr($url, -1)) {
|
||||
$url = substr($url, 0, -1);
|
||||
}
|
||||
|
||||
return $url . '/shop/account/verify/' . $queryParams['uid']
|
||||
. '?shopKey=' . urlencode($this->shopKeysService->getSignature());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
* @throws SshKeysNotFoundException
|
||||
*/
|
||||
public function unlinkShop()
|
||||
{
|
||||
$response = $this->getServicesAccountsClient()->deleteShop((string) $this->configuration->getShopUuid());
|
||||
|
||||
// Réponse: 200: Shop supprimé avec payload contenant un message de confirmation
|
||||
// Réponse: 404: La shop n'existe pas (not found)
|
||||
// Réponse: 401: L'utilisateur n'est pas autorisé à supprimer cette shop
|
||||
|
||||
if ($response['status'] && 200 === $response['httpCode']
|
||||
|| 404 === $response['httpCode']) {
|
||||
$this->resetOnboardingData();
|
||||
|
||||
// FIXME regenerate rsa keys
|
||||
$this->shopKeysService->regenerateKeys();
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty onboarding configuration values
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function resetOnboardingData()
|
||||
{
|
||||
$this->configuration->updateAccountsRsaPrivateKey('');
|
||||
$this->configuration->updateAccountsRsaPublicKey('');
|
||||
$this->configuration->updateAccountsRsaSignData('');
|
||||
|
||||
$this->configuration->updateFirebaseIdAndRefreshTokens('', '');
|
||||
$this->configuration->updateFirebaseEmail('');
|
||||
$this->configuration->updateFirebaseEmailIsVerified(false);
|
||||
|
||||
$this->configuration->updateShopUuid('');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $psxName
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws SshKeysNotFoundException
|
||||
* @throws \PrestaShopException
|
||||
*/
|
||||
public function manageOnboarding($psxName)
|
||||
{
|
||||
$this->shopKeysService->generateKeys();
|
||||
|
||||
$this->updateOnboardingData($psxName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Only callable during onboarding
|
||||
*
|
||||
* Prepare onboarding data
|
||||
*
|
||||
* @param string $psxName
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \PrestaShopException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function updateOnboardingData($psxName)
|
||||
{
|
||||
$email = \Tools::getValue('email');
|
||||
$emailVerified = \Tools::getValue('emailVerified');
|
||||
$customToken = \Tools::getValue('adminToken');
|
||||
|
||||
if (is_string($customToken)) {
|
||||
if (false === $this->shopKeysService->hasKeys()) {
|
||||
throw new \Exception('SSH keys were not found');
|
||||
}
|
||||
|
||||
if (!$this->shopTokenService->exchangeCustomTokenForIdAndRefreshToken($customToken)) {
|
||||
throw new \Exception('Unable to get Firebase token');
|
||||
}
|
||||
|
||||
if (!empty($email)) {
|
||||
$this->configuration->updateFirebaseEmail($email);
|
||||
|
||||
if (!empty($emailVerified)) {
|
||||
$this->configuration->updateFirebaseEmailIsVerified('true' === $emailVerified);
|
||||
}
|
||||
|
||||
// FIXME : quick and dirty fix
|
||||
\Tools::redirectAdmin(
|
||||
$this->link->getAdminLink('AdminModules', true, [], [
|
||||
'configure' => $psxName,
|
||||
])
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isAccountLinked()
|
||||
{
|
||||
return $this->shopTokenService->getToken()
|
||||
&& $this->configuration->getFirebaseEmail();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $config
|
||||
* @param array $defaults
|
||||
*
|
||||
* @return array|mixed
|
||||
*
|
||||
* @throws OptionResolutionException
|
||||
*/
|
||||
public function resolveConfig(array $config, array $defaults = [])
|
||||
{
|
||||
return (new ConfigOptionsResolver([
|
||||
'accounts_ui_url',
|
||||
]))->resolve($config, $defaults);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $hmac
|
||||
* @param string $uid
|
||||
* @param string $path
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws HmacException
|
||||
*/
|
||||
private function writeHmac($hmac, $uid, $path)
|
||||
{
|
||||
if (!is_dir($path)) {
|
||||
mkdir($path);
|
||||
}
|
||||
|
||||
if (!is_writable($path)) {
|
||||
throw new HmacException('Directory isn\'t writable');
|
||||
}
|
||||
|
||||
file_put_contents($path . $uid . '.txt', $hmac);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
* @param string $replacement
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function replaceScheme($url, $replacement = '')
|
||||
{
|
||||
return preg_replace('/^https?:\/\/[^\/]+/', $replacement, $url);
|
||||
}
|
||||
}
|
||||
150
modules/ps_accounts/classes/Service/ShopTokenService.php
Normal file
150
modules/ps_accounts/classes/Service/ShopTokenService.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Service;
|
||||
|
||||
use Lcobucci\JWT\Parser;
|
||||
use PrestaShop\Module\PsAccounts\Api\Client\FirebaseClient;
|
||||
use PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository;
|
||||
|
||||
class ShopTokenService
|
||||
{
|
||||
/**
|
||||
* @var FirebaseClient
|
||||
*/
|
||||
private $firebaseClient;
|
||||
|
||||
/**
|
||||
* @var ConfigurationRepository
|
||||
*/
|
||||
private $configuration;
|
||||
|
||||
/**
|
||||
* ShopTokenService constructor.
|
||||
*
|
||||
* @param FirebaseClient $firebaseClient
|
||||
* @param ConfigurationRepository $configuration
|
||||
*/
|
||||
public function __construct(
|
||||
FirebaseClient $firebaseClient,
|
||||
ConfigurationRepository $configuration
|
||||
) {
|
||||
$this->firebaseClient = $firebaseClient;
|
||||
$this->configuration = $configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://firebase.google.com/docs/reference/rest/auth Firebase documentation
|
||||
*
|
||||
* @param string $customToken
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function exchangeCustomTokenForIdAndRefreshToken($customToken)
|
||||
{
|
||||
$response = $this->firebaseClient->signInWithCustomToken($customToken);
|
||||
|
||||
if ($response && true === $response['status']) {
|
||||
$uid = (new Parser())->parse((string) $customToken)->getClaim('uid');
|
||||
|
||||
$this->configuration->updateShopUuid($uid);
|
||||
|
||||
$this->configuration->updateFirebaseIdAndRefreshTokens(
|
||||
$response['body']['idToken'],
|
||||
$response['body']['refreshToken']
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function refreshToken()
|
||||
{
|
||||
$response = $this->firebaseClient->exchangeRefreshTokenForIdToken(
|
||||
$this->configuration->getFirebaseRefreshToken()
|
||||
);
|
||||
|
||||
if ($response && true === $response['status']) {
|
||||
$this->configuration->updateFirebaseIdAndRefreshTokens(
|
||||
$response['body']['id_token'],
|
||||
$response['body']['refresh_token']
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user firebase token.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getOrRefreshToken()
|
||||
{
|
||||
if (
|
||||
$this->configuration->hasFirebaseRefreshToken()
|
||||
&& $this->isTokenExpired()
|
||||
) {
|
||||
$this->refreshToken();
|
||||
}
|
||||
|
||||
return $this->configuration->getFirebaseIdToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getRefreshToken()
|
||||
{
|
||||
return $this->configuration->getFirebaseRefreshToken() ?: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getToken()
|
||||
{
|
||||
return $this->configuration->getFirebaseIdToken() ?: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function isTokenExpired()
|
||||
{
|
||||
// iat, exp
|
||||
$token = (new Parser())->parse($this->configuration->getFirebaseIdToken());
|
||||
|
||||
return $token->isExpired(new \DateTime());
|
||||
}
|
||||
}
|
||||
91
modules/ps_accounts/classes/Service/SsoService.php
Normal file
91
modules/ps_accounts/classes/Service/SsoService.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Service;
|
||||
|
||||
use Context;
|
||||
use PrestaShop\Module\PsAccounts\Configuration\ConfigOptionsResolver;
|
||||
use PrestaShop\Module\PsAccounts\Configuration\Configurable;
|
||||
use PrestaShop\Module\PsAccounts\Exception\OptionResolutionException;
|
||||
|
||||
/**
|
||||
* Class PsAccountsService
|
||||
*/
|
||||
class SsoService implements Configurable
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $ssoAccountUrl;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $ssoResendVerificationEmailUrl;
|
||||
|
||||
/**
|
||||
* PsAccountsService constructor.
|
||||
*
|
||||
* @param array $config
|
||||
*
|
||||
* @throws OptionResolutionException
|
||||
*/
|
||||
public function __construct(array $config)
|
||||
{
|
||||
$config = $this->resolveConfig($config);
|
||||
$this->ssoAccountUrl = $config['sso_account_url'];
|
||||
$this->ssoResendVerificationEmailUrl = $config['sso_resend_verification_email_url'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSsoAccountUrl()
|
||||
{
|
||||
$url = $this->ssoAccountUrl;
|
||||
$langIsoCode = Context::getContext()->language->iso_code;
|
||||
|
||||
return $url . '?lang=' . substr($langIsoCode, 0, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSsoResendVerificationEmailUrl()
|
||||
{
|
||||
return $this->ssoResendVerificationEmailUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $config
|
||||
* @param array $defaults
|
||||
*
|
||||
* @return array|mixed
|
||||
*
|
||||
* @throws OptionResolutionException
|
||||
*/
|
||||
public function resolveConfig(array $config, array $defaults = [])
|
||||
{
|
||||
return (new ConfigOptionsResolver([
|
||||
'sso_account_url',
|
||||
'sso_resend_verification_email_url',
|
||||
]))->resolve($config, $defaults);
|
||||
}
|
||||
}
|
||||
28
modules/ps_accounts/classes/Service/index.php
Normal file
28
modules/ps_accounts/classes/Service/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\Translations;
|
||||
|
||||
use Context;
|
||||
use Ps_accounts;
|
||||
|
||||
class SettingsTranslations
|
||||
{
|
||||
/**
|
||||
* @var Ps_accounts
|
||||
*/
|
||||
private $module;
|
||||
|
||||
/**
|
||||
* __construct
|
||||
*
|
||||
* @param Ps_accounts $module
|
||||
*/
|
||||
public function __construct(Ps_accounts $module)
|
||||
{
|
||||
$this->module = $module;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create all translations for Settings App
|
||||
*
|
||||
* @return array translation list
|
||||
*/
|
||||
public function getTranslations()
|
||||
{
|
||||
$locale = Context::getContext()->language->iso_code;
|
||||
$class = 'SettingsTranslations';
|
||||
|
||||
$translations[$locale] = [
|
||||
'general' => [
|
||||
'settings' => $this->module->l('settings.settings', $class),
|
||||
'help' => $this->module->l('settings.help', $class),
|
||||
],
|
||||
'configure' => [
|
||||
'incentivePanel' => [
|
||||
'title' => $this->module->l('settings.title', $class),
|
||||
'howTo' => $this->module->l('settings.sub_title', $class),
|
||||
'createPsAccount' => $this->module->l('settings.step_1', $class),
|
||||
'linkPsAccount' => $this->module->l('settings.step_2', $class),
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
return $translations;
|
||||
}
|
||||
}
|
||||
28
modules/ps_accounts/classes/Translations/index.php
Normal file
28
modules/ps_accounts/classes/Translations/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
219
modules/ps_accounts/classes/WebHook/Validator.php
Normal file
219
modules/ps_accounts/classes/WebHook/Validator.php
Normal file
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsAccounts\WebHook;
|
||||
|
||||
use Context;
|
||||
use PrestaShop\Module\PsAccounts\Api\Client\ServicesAccountsClient;
|
||||
use PrestaShop\Module\PsAccounts\Exception\WebhookException;
|
||||
use PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository;
|
||||
|
||||
class Validator
|
||||
{
|
||||
const HEADER_DATA_ERROR = 'CorrelationId in headers can\'t be empty';
|
||||
const BODY_ERROR = 'Body can\'t be empty';
|
||||
const BODY_SERVICE_ERROR = 'Service can\'t be empty';
|
||||
const BODY_ACTION_ERROR = 'Action can\'t be empty';
|
||||
const BODY_DATA_ERROR = 'Data can\'t be empty';
|
||||
const BODY_DATA_OWNERID_ERROR = 'OwnerId can\'t be empty';
|
||||
const BODY_DATA_SHOPID_ERROR = 'ShopId can\'t be empty';
|
||||
const BODY_OTHER_ERROR = 'ShopId can\'t be empty';
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $statusCode = 200;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $message = '';
|
||||
|
||||
/**
|
||||
* @var Context
|
||||
*/
|
||||
private $context;
|
||||
|
||||
/**
|
||||
* @var ConfigurationRepository
|
||||
*/
|
||||
private $configuration;
|
||||
|
||||
/**
|
||||
* @var ServicesAccountsClient
|
||||
*/
|
||||
private $accountsClient;
|
||||
|
||||
/**
|
||||
* Validator constructor.
|
||||
*
|
||||
* @param ServicesAccountsClient $accountsClient
|
||||
* @param ConfigurationRepository $configuration
|
||||
* @param Context $context
|
||||
*/
|
||||
public function __construct(
|
||||
ServicesAccountsClient $accountsClient,
|
||||
ConfigurationRepository $configuration,
|
||||
Context $context
|
||||
) {
|
||||
$this->accountsClient = $accountsClient;
|
||||
|
||||
$this->configuration = $configuration;
|
||||
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the webHook data
|
||||
*
|
||||
* @param array $headerValues
|
||||
* @param array $payload
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function validateData($headerValues = [], $payload = [])
|
||||
{
|
||||
// TODO check empty
|
||||
return array_merge(
|
||||
$this->validateHeaderData($headerValues),
|
||||
$this->validateBodyData($payload)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the webHook header data
|
||||
*
|
||||
* @param array $headerValues
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function validateHeaderData(array $headerValues)
|
||||
{
|
||||
$errors = [];
|
||||
if (empty($headerValues['correlationId'])) {
|
||||
$errors[] = self::HEADER_DATA_ERROR;
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the webHook body data
|
||||
*
|
||||
* @param array $payload
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function validateBodyData(array $payload)
|
||||
{
|
||||
$errors = [];
|
||||
if (empty($payload)) {
|
||||
$errors[] = self::BODY_ERROR;
|
||||
}
|
||||
|
||||
if (empty($payload['service'])) {
|
||||
$errors[] = self::BODY_SERVICE_ERROR;
|
||||
}
|
||||
|
||||
if (empty($payload['action'])) {
|
||||
$errors[] = self::BODY_ACTION_ERROR;
|
||||
}
|
||||
|
||||
if (empty($payload['data'])) {
|
||||
$errors[] = self::BODY_DATA_ERROR;
|
||||
}
|
||||
|
||||
if (empty($payload['data']['ownerId'])) {
|
||||
$errors[] = self::BODY_DATA_OWNERID_ERROR;
|
||||
}
|
||||
if (empty($payload['data']['shopId'])) {
|
||||
$errors[] = self::BODY_DATA_SHOPID_ERROR;
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the webHook data
|
||||
*
|
||||
* @param array $headerValues
|
||||
* @param array $bodyValues
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws WebhookException
|
||||
* @throws \PrestaShopException
|
||||
*/
|
||||
public function validate($headerValues = [], $bodyValues = [])
|
||||
{
|
||||
$errors = $this->validateData($headerValues, $bodyValues);
|
||||
// No verifyWebhook if data validation fails.
|
||||
$errors = empty($errors) ? $this->verifyWebhook($headerValues, $bodyValues) : $errors;
|
||||
|
||||
if (!empty($errors)) {
|
||||
throw new WebhookException((string) json_encode($errors));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the IP whitelist and Shop, Merchant and Psx Ids
|
||||
*
|
||||
* @param array $shopId
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function checkExecutionPermissions($shopId)
|
||||
{
|
||||
$dbShopId = $this->configuration->getShopUuid();
|
||||
if ($shopId != $dbShopId) {
|
||||
$output = [
|
||||
'status_code' => 500,
|
||||
'message' => 'ShopId don\'t match. You aren\'t authorized',
|
||||
];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the Webhook comes from the PSL
|
||||
*
|
||||
* @param array $headerValues
|
||||
* @param array $bodyValues
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \PrestaShopException
|
||||
*/
|
||||
private function verifyWebhook(array $headerValues = [], array $bodyValues = [])
|
||||
{
|
||||
//$response = (new AccountsClient($this->context->link))->checkWebhookAuthenticity($headerValues, $bodyValues);
|
||||
|
||||
$response = $this->accountsClient->verifyWebhook($headerValues, $bodyValues);
|
||||
|
||||
if (!$response || 200 > $response['httpCode'] || 299 < $response['httpCode']) {
|
||||
return [$response['body'] ? $response['body'] : 'Webhook not verified'];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
28
modules/ps_accounts/classes/WebHook/index.php
Normal file
28
modules/ps_accounts/classes/WebHook/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
28
modules/ps_accounts/classes/index.php
Normal file
28
modules/ps_accounts/classes/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
13
modules/ps_accounts/config.xml
Normal file
13
modules/ps_accounts/config.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<module>
|
||||
<name>ps_accounts</name>
|
||||
<displayName><![CDATA[PrestaShop Account]]></displayName>
|
||||
<version><![CDATA[4.0.0]]></version>
|
||||
<description><![CDATA[Link your PrestaShop account to your online shop to activate & manage services on your back-office. Don't uninstall this module if you are already using a service, as it will prevent it from working.]]></description>
|
||||
<author><![CDATA[PrestaShop]]></author>
|
||||
<tab><![CDATA[administration]]></tab>
|
||||
<confirmUninstall><![CDATA[This action will prevent immediately your PrestaShop services and Community services from working as they are using PrestaShop Accounts module for authentication.]]></confirmUninstall>
|
||||
<is_configurable>1</is_configurable>
|
||||
<need_instance>0</need_instance>
|
||||
<limited_countries></limited_countries>
|
||||
</module>
|
||||
28
modules/ps_accounts/config/admin/index.php
Normal file
28
modules/ps_accounts/config/admin/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
2
modules/ps_accounts/config/admin/services.yml
Normal file
2
modules/ps_accounts/config/admin/services.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
imports:
|
||||
- { resource: ../config.yml }
|
||||
147
modules/ps_accounts/config/common.yml
Normal file
147
modules/ps_accounts/config/common.yml
Normal file
@@ -0,0 +1,147 @@
|
||||
services:
|
||||
_defaults:
|
||||
public: true
|
||||
|
||||
ps_accounts.module:
|
||||
class: Ps_accounts
|
||||
factory: ['Module', 'getInstanceByName']
|
||||
arguments:
|
||||
- 'ps_accounts'
|
||||
|
||||
ps_accounts.context:
|
||||
class: Context
|
||||
factory: [ 'Context', 'getContext' ]
|
||||
|
||||
PrestaShop\Module\PsAccounts\Context\ShopContext:
|
||||
class: PrestaShop\Module\PsAccounts\Context\ShopContext
|
||||
arguments:
|
||||
- '@PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository'
|
||||
- '@ps_accounts.context'
|
||||
|
||||
PrestaShop\Module\PsAccounts\Adapter\Configuration:
|
||||
class: PrestaShop\Module\PsAccounts\Adapter\Configuration
|
||||
arguments:
|
||||
- '@ps_accounts.context'
|
||||
|
||||
PrestaShop\Module\PsAccounts\Adapter\Link:
|
||||
class: PrestaShop\Module\PsAccounts\Adapter\Link
|
||||
arguments:
|
||||
- '@PrestaShop\Module\PsAccounts\Context\ShopContext'
|
||||
|
||||
#####################
|
||||
# installer
|
||||
|
||||
PrestaShop\Module\PsAccounts\Installer\Installer:
|
||||
class: PrestaShop\Module\PsAccounts\Installer\Installer
|
||||
arguments:
|
||||
- '@PrestaShop\Module\PsAccounts\Context\ShopContext'
|
||||
- '@PrestaShop\Module\PsAccounts\Adapter\Link'
|
||||
|
||||
#####################
|
||||
# services
|
||||
|
||||
PrestaShop\Module\PsAccounts\Service\ShopKeysService:
|
||||
class: PrestaShop\Module\PsAccounts\Service\ShopKeysService
|
||||
arguments:
|
||||
- '@PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository'
|
||||
|
||||
PrestaShop\Module\PsAccounts\Service\ShopTokenService:
|
||||
class: PrestaShop\Module\PsAccounts\Service\ShopTokenService
|
||||
arguments:
|
||||
- '@PrestaShop\Module\PsAccounts\Api\Client\FirebaseClient'
|
||||
- '@PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository'
|
||||
|
||||
PrestaShop\Module\PsAccounts\Service\PsAccountsService:
|
||||
class: PrestaShop\Module\PsAccounts\Service\PsAccountsService
|
||||
arguments:
|
||||
- '@ps_accounts.module'
|
||||
- '@PrestaShop\Module\PsAccounts\Service\ShopTokenService'
|
||||
- '@PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository'
|
||||
- '@PrestaShop\Module\PsAccounts\Adapter\Link'
|
||||
|
||||
PrestaShop\Module\PsAccounts\Service\SsoService:
|
||||
class: PrestaShop\Module\PsAccounts\Service\SsoService
|
||||
arguments:
|
||||
- { sso_resend_verification_email_url: '%ps_accounts.sso_resend_verification_email_url%',
|
||||
sso_account_url: '%ps_accounts.sso_account_url%' }
|
||||
|
||||
PrestaShop\Module\PsAccounts\Service\ShopLinkAccountService:
|
||||
class: PrestaShop\Module\PsAccounts\Service\ShopLinkAccountService
|
||||
arguments:
|
||||
- { accounts_ui_url: '%ps_accounts.svc_accounts_ui_url%' }
|
||||
- '@PrestaShop\Module\PsAccounts\Provider\ShopProvider'
|
||||
- '@PrestaShop\Module\PsAccounts\Service\ShopKeysService'
|
||||
- '@PrestaShop\Module\PsAccounts\Service\ShopTokenService'
|
||||
- '@PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository'
|
||||
- '@PrestaShop\Module\PsAccounts\Adapter\Link'
|
||||
|
||||
PrestaShop\Module\PsAccounts\Service\PsBillingService:
|
||||
class: PrestaShop\Module\PsAccounts\Service\PsBillingService
|
||||
arguments:
|
||||
- '@PrestaShop\Module\PsAccounts\Api\Client\ServicesBillingClient'
|
||||
- '@PrestaShop\Module\PsAccounts\Service\ShopTokenService'
|
||||
- '@PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository'
|
||||
|
||||
#####################
|
||||
# providers
|
||||
|
||||
PrestaShop\Module\PsAccounts\Provider\ShopProvider:
|
||||
class: PrestaShop\Module\PsAccounts\Provider\ShopProvider
|
||||
arguments:
|
||||
- '@PrestaShop\Module\PsAccounts\Context\ShopContext'
|
||||
- '@PrestaShop\Module\PsAccounts\Adapter\Link'
|
||||
|
||||
#####################
|
||||
# handlers
|
||||
|
||||
PrestaShop\Module\PsAccounts\Handler\Error\Sentry:
|
||||
class: PrestaShop\Module\PsAccounts\Handler\Error\Sentry
|
||||
arguments:
|
||||
- '%ps_accounts.sentry_credentials%'
|
||||
- '@=service("ps_accounts.module").getModuleEnv()'
|
||||
- '@PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository'
|
||||
|
||||
###############
|
||||
# api clients
|
||||
|
||||
PrestaShop\Module\PsAccounts\Api\Client\FirebaseClient:
|
||||
class: PrestaShop\Module\PsAccounts\Api\Client\FirebaseClient
|
||||
arguments:
|
||||
- { api_key: '%ps_accounts.firebase_api_key%' }
|
||||
|
||||
PrestaShop\Module\PsAccounts\Api\Client\ServicesBillingClient:
|
||||
class: PrestaShop\Module\PsAccounts\Api\Client\ServicesBillingClient
|
||||
arguments:
|
||||
- { api_url: '%ps_accounts.svc_billing_api_url%' }
|
||||
- '@PrestaShop\Module\PsAccounts\Service\PsAccountsService'
|
||||
- '@PrestaShop\Module\PsAccounts\Provider\ShopProvider'
|
||||
- '@PrestaShop\Module\PsAccounts\Adapter\Link'
|
||||
|
||||
PrestaShop\Module\PsAccounts\Api\Client\ServicesAccountsClient:
|
||||
class: PrestaShop\Module\PsAccounts\Api\Client\ServicesAccountsClient
|
||||
arguments:
|
||||
- { api_url: '%ps_accounts.svc_accounts_api_url%' }
|
||||
- '@PrestaShop\Module\PsAccounts\Provider\ShopProvider'
|
||||
- '@PrestaShop\Module\PsAccounts\Service\ShopTokenService'
|
||||
- '@PrestaShop\Module\PsAccounts\Adapter\Link'
|
||||
|
||||
#####################
|
||||
# repositories
|
||||
|
||||
PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository:
|
||||
class: PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository
|
||||
arguments:
|
||||
- '@PrestaShop\Module\PsAccounts\Adapter\Configuration'
|
||||
|
||||
#####################
|
||||
# presenters
|
||||
|
||||
PrestaShop\Module\PsAccounts\Presenter\PsAccountsPresenter:
|
||||
class: PrestaShop\Module\PsAccounts\Presenter\PsAccountsPresenter
|
||||
arguments:
|
||||
- '@PrestaShop\Module\PsAccounts\Service\PsAccountsService'
|
||||
- '@PrestaShop\Module\PsAccounts\Provider\ShopProvider'
|
||||
- '@PrestaShop\Module\PsAccounts\Service\ShopLinkAccountService'
|
||||
- '@PrestaShop\Module\PsAccounts\Service\SsoService'
|
||||
- '@PrestaShop\Module\PsAccounts\Installer\Installer'
|
||||
- '@PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository'
|
||||
10
modules/ps_accounts/config/config.yml
Normal file
10
modules/ps_accounts/config/config.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
imports:
|
||||
- { resource: common.yml }
|
||||
parameters:
|
||||
ps_accounts.firebase_api_key: 'AIzaSyBEm26bA2KR893rY68enLdVGpqnkoW2Juo'
|
||||
ps_accounts.svc_accounts_api_url: 'https://accounts-api.psessentials.net'
|
||||
ps_accounts.svc_accounts_ui_url: 'https://accounts.psessentials.net'
|
||||
ps_accounts.svc_billing_api_url: 'https://billing-api.distribution.prestashop.net'
|
||||
ps_accounts.sso_account_url: 'https://auth.prestashop.com/login'
|
||||
ps_accounts.sso_resend_verification_email_url: 'https://auth.prestashop.com/account/send-verification-email'
|
||||
ps_accounts.sentry_credentials: 'https://4c7f6c8dd5aa405b8401a35f5cf26ada@o298402.ingest.sentry.io/5354585'
|
||||
19
modules/ps_accounts/config/config.yml.dist
Normal file
19
modules/ps_accounts/config/config.yml.dist
Normal file
@@ -0,0 +1,19 @@
|
||||
imports:
|
||||
- { resource: common.yml }
|
||||
|
||||
parameters:
|
||||
# In case you need to override with environment variables, you can follow this example :
|
||||
# env(PS_ACCOUNTS_SENTRY_CREDENTIALS): 'https://4c7f6c8dd5aa405b8401a35f5cf26ada@o298402.ingest.sentry.io/5354585'
|
||||
# sentry.credentials: '%env(string:PS_ACCOUNTS_SENTRY_CREDENTIALS)%'
|
||||
#
|
||||
# In order to manage multiple config files you can use PS_ACCOUNTS_ENV=[myenv] environment variable
|
||||
# to load a specific services_[myenv].yml
|
||||
|
||||
# prestashop-ready-integration.firebaseapp.com
|
||||
ps_accounts.firebase_api_key: 'AIzaSyASHFE2F08ncoOH9NhoCF8_6z7qnoLVKSA'
|
||||
ps_accounts.svc_accounts_api_url: 'http://accounts-api:3000'
|
||||
ps_accounts.svc_accounts_ui_url: 'http://localhost:8080'
|
||||
ps_accounts.svc_billing_api_url: 'https://billing-api.psessentials-integration.net'
|
||||
ps_accounts.sso_account_url: 'https://prestashop-newsso-staging.appspot.com/login'
|
||||
ps_accounts.sso_resend_verification_email_url: 'https://prestashop-newsso-staging.appspot.com/account/send-verification-email'
|
||||
ps_accounts.sentry_credentials: 'https://4c7f6c8dd5aa405b8401a35f5cf26ada@o298402.ingest.sentry.io/5354585'
|
||||
28
modules/ps_accounts/config/front/index.php
Normal file
28
modules/ps_accounts/config/front/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
2
modules/ps_accounts/config/front/services.yml
Normal file
2
modules/ps_accounts/config/front/services.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
imports:
|
||||
- { resource: ../config.yml }
|
||||
28
modules/ps_accounts/config/index.php
Normal file
28
modules/ps_accounts/config/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
13
modules/ps_accounts/config_pl.xml
Normal file
13
modules/ps_accounts/config_pl.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<module>
|
||||
<name>ps_accounts</name>
|
||||
<displayName><![CDATA[Konto PrestaShop]]></displayName>
|
||||
<version><![CDATA[4.0.0]]></version>
|
||||
<description><![CDATA[Połącz swój sklep z kontem PrestaShop, aby aktywować i zarządzać subskrypcjami w swoim back office. Nie odinstalowuj tego modułu, jeśli masz aktualną subskrypcję.]]></description>
|
||||
<author><![CDATA[PrestaShop]]></author>
|
||||
<tab><![CDATA[administration]]></tab>
|
||||
<confirmUninstall><![CDATA[This action will prevent immediately your PrestaShop services and Community services from working as they are using PrestaShop Accounts module for authentication.]]></confirmUninstall>
|
||||
<is_configurable>1</is_configurable>
|
||||
<need_instance>0</need_instance>
|
||||
<limited_countries></limited_countries>
|
||||
</module>
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
use PrestaShop\Module\PsAccounts\Handler\Error\Sentry;
|
||||
use PrestaShop\Module\PsAccounts\Presenter\PsAccountsPresenter;
|
||||
use PrestaShop\Module\PsAccounts\Service\ShopLinkAccountService;
|
||||
use PrestaShop\Module\PsAccounts\Service\ShopTokenService;
|
||||
|
||||
/**
|
||||
* Controller for all ajax calls.
|
||||
*/
|
||||
class AdminAjaxPsAccountsController extends ModuleAdminController
|
||||
{
|
||||
/**
|
||||
* @var Ps_accounts
|
||||
*/
|
||||
public $module;
|
||||
|
||||
/**
|
||||
* AdminAjaxPsAccountsController constructor.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function ajaxProcessGetOrRefreshToken()
|
||||
{
|
||||
try {
|
||||
/** @var ShopTokenService $shopTokenService */
|
||||
$shopTokenService = $this->module->getService(ShopTokenService::class);
|
||||
|
||||
header('Content-Type: text/json');
|
||||
|
||||
$this->ajaxDie(
|
||||
json_encode([
|
||||
'token' => $shopTokenService->getOrRefreshToken(),
|
||||
'refreshToken' => $shopTokenService->getRefreshToken(),
|
||||
])
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
Sentry::captureAndRethrow($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
//public function displayAjaxUnlinkShop()
|
||||
public function ajaxProcessUnlinkShop()
|
||||
{
|
||||
try {
|
||||
/** @var ShopLinkAccountService $shopLinkAccountService */
|
||||
$shopLinkAccountService = $this->module->getService(ShopLinkAccountService::class);
|
||||
|
||||
$response = $shopLinkAccountService->unlinkShop();
|
||||
|
||||
http_response_code($response['httpCode']);
|
||||
|
||||
header('Content-Type: text/json');
|
||||
|
||||
$this->ajaxDie(json_encode($response['body']));
|
||||
} catch (Exception $e) {
|
||||
Sentry::captureAndRethrow($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function ajaxProcessGetContext()
|
||||
{
|
||||
try {
|
||||
$psxName = Tools::getValue('psx_name');
|
||||
|
||||
/** @var PsAccountsPresenter $presenter */
|
||||
$presenter = $this->module->getService(PsAccountsPresenter::class);
|
||||
|
||||
header('Content-Type: text/json');
|
||||
|
||||
$this->ajaxDie(json_encode($presenter->present($psxName)));
|
||||
} catch (Exception $e) {
|
||||
Sentry::captureAndRethrow($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
use PrestaShop\Module\PsAccounts\Handler\Error\Sentry;
|
||||
use PrestaShop\Module\PsAccounts\Service\ShopLinkAccountService;
|
||||
|
||||
/**
|
||||
* Controller generate hmac and redirect on hmac's file.
|
||||
*/
|
||||
class AdminConfigureHmacPsAccountsController extends ModuleAdminController
|
||||
{
|
||||
/**
|
||||
* @var Ps_accounts
|
||||
*/
|
||||
public $module;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function initContent()
|
||||
{
|
||||
try {
|
||||
/** @var ShopLinkAccountService $shopLinkAccountService */
|
||||
$shopLinkAccountService = $this->module->getService(ShopLinkAccountService::class);
|
||||
|
||||
Tools::redirect(
|
||||
$shopLinkAccountService->getVerifyAccountUrl(
|
||||
Tools::getAllValues(),
|
||||
_PS_ROOT_DIR_
|
||||
)
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
Sentry::captureAndRethrow($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
use PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository;
|
||||
use PrestaShop\Module\PsAccounts\Service\PsAccountsService;
|
||||
|
||||
/**
|
||||
* 2007-2020 PrestaShop and Contributors.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2020 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
class AdminDebugPsAccountsController extends ModuleAdminController
|
||||
{
|
||||
/**
|
||||
* @var Ps_accounts
|
||||
*/
|
||||
public $module;
|
||||
|
||||
/**
|
||||
* @var ConfigurationRepository
|
||||
*/
|
||||
private $configuration;
|
||||
|
||||
/**
|
||||
* @var PsAccountsService
|
||||
*/
|
||||
private $psAccountsService;
|
||||
|
||||
/**
|
||||
* AdminDebugController constructor.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->configuration = $this->module->getService(ConfigurationRepository::class);
|
||||
$this->psAccountsService = $this->module->getService(PsAccountsService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*
|
||||
* @throws SmartyException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function initContent()
|
||||
{
|
||||
$this->context->smarty->assign([
|
||||
'config' => [
|
||||
'shopId' => (int) $this->context->shop->id,
|
||||
'shopUuidV4' => $this->configuration->getShopUuid(),
|
||||
'moduleVersion' => \Ps_accounts::VERSION,
|
||||
'psVersion' => _PS_VERSION_,
|
||||
'phpVersion' => phpversion(),
|
||||
'firebase_email' => $this->configuration->getFirebaseEmail(),
|
||||
'firebase_email_is_verified' => $this->configuration->firebaseEmailIsVerified(),
|
||||
'firebase_id_token' => $this->configuration->getFirebaseIdToken(),
|
||||
'firebase_refresh_token' => $this->configuration->getFirebaseRefreshToken(),
|
||||
'unlinkShopUrl' => 'index.php?controller=AdminAjaxPsAccounts&ajax=1&action=unlinkShop&token=' . Tools::getAdminTokenLite('AdminAjaxPsAccounts'),
|
||||
'isShopLinked' => $this->psAccountsService->isAccountLinked(),
|
||||
],
|
||||
]);
|
||||
$this->content = $this->context->smarty->fetch($this->module->getLocalPath() . '/views/templates/admin/debug.tpl');
|
||||
parent::initContent();
|
||||
}
|
||||
}
|
||||
28
modules/ps_accounts/controllers/admin/index.php
Normal file
28
modules/ps_accounts/controllers/admin/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
201
modules/ps_accounts/controllers/front/DispatchWebHook.php
Normal file
201
modules/ps_accounts/controllers/front/DispatchWebHook.php
Normal file
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
use PrestaShop\Module\PsAccounts\Api\Client\ServicesAccountsClient;
|
||||
use PrestaShop\Module\PsAccounts\Exception\WebhookException;
|
||||
use PrestaShop\Module\PsAccounts\Handler\Error\Sentry;
|
||||
use PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository;
|
||||
use PrestaShop\Module\PsAccounts\WebHook\Validator;
|
||||
|
||||
class ps_accountsDispatchWebHookModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
const PS_CHECKOUT_SHOP_UUID_V4 = 'PS_CHECKOUT_SHOP_UUID_V4';
|
||||
|
||||
/**
|
||||
* @var Ps_accounts
|
||||
*/
|
||||
public $module;
|
||||
|
||||
/**
|
||||
* @var ConfigurationRepository
|
||||
*/
|
||||
private $configuration;
|
||||
|
||||
/**
|
||||
* Id coming from PSL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $shopId;
|
||||
|
||||
/**
|
||||
* Id coming from Paypal
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $merchantId;
|
||||
|
||||
/**
|
||||
* Id coming from Firebase
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $firebaseId;
|
||||
|
||||
/**
|
||||
* ps_accountsDispatchWebHookModuleFrontController constructor.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->configuration = $this->module->getService(ConfigurationRepository::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the webhook script
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function display()
|
||||
{
|
||||
$validator = new Validator(
|
||||
$this->module->getService(ServicesAccountsClient::class),
|
||||
$this->configuration,
|
||||
$this->module->getService('ps_accounts.context')
|
||||
);
|
||||
|
||||
try {
|
||||
$headers = getallheaders();
|
||||
$body = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
$validator->validate(
|
||||
$headers,
|
||||
$body
|
||||
);
|
||||
|
||||
$this->generateHttpResponse(
|
||||
$this->dispatchWebhook($headers, $body)
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
Sentry::captureAndRethrow($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch webhook to service (or fallback here for 'accounts' service)
|
||||
*
|
||||
* @param array $bodyValues
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws WebhookException
|
||||
* @throws PrestaShopException
|
||||
*/
|
||||
private function dispatchWebhook(array $headers, array $bodyValues)
|
||||
{
|
||||
$moduleName = $bodyValues['service'];
|
||||
if ($moduleName && $moduleName !== 'ps_accounts') {
|
||||
/** @var Module $module */
|
||||
$module = Module::getInstanceByName($moduleName);
|
||||
|
||||
$error = Hook::exec(
|
||||
'receiveWebhook_' . $moduleName,
|
||||
['headers' => $headers, 'body' => $bodyValues],
|
||||
$module->id
|
||||
);
|
||||
|
||||
if ($error === '') {
|
||||
return [
|
||||
'status_code' => 200,
|
||||
'message' => 'ok',
|
||||
];
|
||||
}
|
||||
throw new WebhookException($error);
|
||||
} else {
|
||||
return $this->receiveAccountsWebhook($headers, $bodyValues);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Override displayMaintenancePage to prevent the maintenance page to be displayed
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function displayMaintenancePage()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Override geolocationManagement to prevent country GEOIP blocking
|
||||
*
|
||||
* @param Country $defaultCountry
|
||||
*
|
||||
* @return false
|
||||
*/
|
||||
protected function geolocationManagement($defaultCountry)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $headers
|
||||
* @param array $body
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function receiveAccountsWebhook($headers, $body)
|
||||
{
|
||||
switch ($body['action']) {
|
||||
case 'EmailVerified':
|
||||
$this->configuration->updateFirebaseEmailIsVerified(true);
|
||||
|
||||
return [
|
||||
'status_code' => 200,
|
||||
'message' => 'ok',
|
||||
];
|
||||
|
||||
// TODO : Other cases
|
||||
|
||||
default: // unknown action
|
||||
return [
|
||||
'status_code' => 500,
|
||||
'message' => 'Action unknown',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $output
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function generateHttpResponse(array $output)
|
||||
{
|
||||
header('Content-type: application/json');
|
||||
http_response_code($output['status_code']);
|
||||
echo json_encode($output['message']);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
42
modules/ps_accounts/controllers/front/apiCarts.php
Normal file
42
modules/ps_accounts/controllers/front/apiCarts.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
class ps_AccountsApiCartsModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function postProcess()
|
||||
{
|
||||
if (Module::isInstalled('ps_eventbus')) {
|
||||
Tools::redirect($this->context->link->getModuleLink(
|
||||
'ps_eventbus',
|
||||
'apiCarts',
|
||||
[
|
||||
'job_id' => Tools::getValue('job_id', ''),
|
||||
'limit' => Tools::getValue('limit'),
|
||||
'full' => Tools::getValue('full'),
|
||||
],
|
||||
null,
|
||||
null,
|
||||
$this->context->shop->id
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
42
modules/ps_accounts/controllers/front/apiCategories.php
Normal file
42
modules/ps_accounts/controllers/front/apiCategories.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
class ps_AccountsApiCategoriesModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function postProcess()
|
||||
{
|
||||
if (Module::isInstalled('ps_eventbus')) {
|
||||
Tools::redirect($this->context->link->getModuleLink(
|
||||
'ps_eventbus',
|
||||
'apiCategories',
|
||||
[
|
||||
'job_id' => Tools::getValue('job_id', ''),
|
||||
'limit' => Tools::getValue('limit'),
|
||||
'full' => Tools::getValue('full'),
|
||||
],
|
||||
null,
|
||||
null,
|
||||
$this->context->shop->id
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
42
modules/ps_accounts/controllers/front/apiDeletedObjects.php
Normal file
42
modules/ps_accounts/controllers/front/apiDeletedObjects.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
class ps_AccountsApiDeletedObjectsModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function postProcess()
|
||||
{
|
||||
if (Module::isInstalled('ps_eventbus')) {
|
||||
Tools::redirect($this->context->link->getModuleLink(
|
||||
'ps_eventbus',
|
||||
'apiDeletedObjects',
|
||||
[
|
||||
'job_id' => Tools::getValue('job_id', ''),
|
||||
'limit' => Tools::getValue('limit'),
|
||||
'full' => Tools::getValue('full'),
|
||||
],
|
||||
null,
|
||||
null,
|
||||
$this->context->shop->id
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
class ps_AccountsApiGoogleTaxonomiesModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function postProcess()
|
||||
{
|
||||
if (Module::isInstalled('ps_eventbus')) {
|
||||
Tools::redirect($this->context->link->getModuleLink(
|
||||
'ps_eventbus',
|
||||
'apiGoogleTaxonomies',
|
||||
[
|
||||
'job_id' => Tools::getValue('job_id', ''),
|
||||
'limit' => Tools::getValue('limit'),
|
||||
'full' => Tools::getValue('full'),
|
||||
],
|
||||
null,
|
||||
null,
|
||||
$this->context->shop->id
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
45
modules/ps_accounts/controllers/front/apiHealthCheck.php
Normal file
45
modules/ps_accounts/controllers/front/apiHealthCheck.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
class ps_AccountsApiHealthCheckModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function postProcess()
|
||||
{
|
||||
if (Module::isInstalled('ps_eventbus')) {
|
||||
Tools::redirect($this->context->link->getModuleLink(
|
||||
'ps_eventbus',
|
||||
'apiHealthCheck',
|
||||
[],
|
||||
null,
|
||||
null,
|
||||
$this->context->shop->id
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
40
modules/ps_accounts/controllers/front/apiInfo.php
Normal file
40
modules/ps_accounts/controllers/front/apiInfo.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
class ps_AccountsApiInfoModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function postProcess()
|
||||
{
|
||||
if (Module::isInstalled('ps_eventbus')) {
|
||||
Tools::redirect($this->context->link->getModuleLink(
|
||||
'ps_eventbus',
|
||||
'apiInfo',
|
||||
[
|
||||
'job_id' => Tools::getValue('job_id', ''),
|
||||
],
|
||||
null,
|
||||
null,
|
||||
$this->context->shop->id
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
42
modules/ps_accounts/controllers/front/apiModules.php
Normal file
42
modules/ps_accounts/controllers/front/apiModules.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
class ps_AccountsApiModulesModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function postProcess()
|
||||
{
|
||||
if (Module::isInstalled('ps_eventbus')) {
|
||||
Tools::redirect($this->context->link->getModuleLink(
|
||||
'ps_eventbus',
|
||||
'apiModules',
|
||||
[
|
||||
'job_id' => Tools::getValue('job_id', ''),
|
||||
'limit' => Tools::getValue('limit'),
|
||||
'full' => Tools::getValue('full'),
|
||||
],
|
||||
null,
|
||||
null,
|
||||
$this->context->shop->id
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
42
modules/ps_accounts/controllers/front/apiOrders.php
Normal file
42
modules/ps_accounts/controllers/front/apiOrders.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
class ps_AccountsApiOrdersModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function postProcess()
|
||||
{
|
||||
if (Module::isInstalled('ps_eventbus')) {
|
||||
Tools::redirect($this->context->link->getModuleLink(
|
||||
'ps_eventbus',
|
||||
'apiOrders',
|
||||
[
|
||||
'job_id' => Tools::getValue('job_id', ''),
|
||||
'limit' => Tools::getValue('limit'),
|
||||
'full' => Tools::getValue('full'),
|
||||
],
|
||||
null,
|
||||
null,
|
||||
$this->context->shop->id
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
44
modules/ps_accounts/controllers/front/apiProducts.php
Normal file
44
modules/ps_accounts/controllers/front/apiProducts.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
class ps_accountsApiProductsModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
/**
|
||||
* @throws PrestaShopException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function postProcess()
|
||||
{
|
||||
if (Module::isInstalled('ps_eventbus')) {
|
||||
Tools::redirect($this->context->link->getModuleLink(
|
||||
'ps_eventbus',
|
||||
'apiProducts',
|
||||
[
|
||||
'job_id' => Tools::getValue('job_id', ''),
|
||||
'limit' => Tools::getValue('limit'),
|
||||
'full' => Tools::getValue('full'),
|
||||
],
|
||||
null,
|
||||
null,
|
||||
$this->context->shop->id
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
42
modules/ps_accounts/controllers/front/apiThemes.php
Normal file
42
modules/ps_accounts/controllers/front/apiThemes.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
class ps_AccountsApiThemesModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function postProcess()
|
||||
{
|
||||
if (Module::isInstalled('ps_eventbus')) {
|
||||
Tools::redirect($this->context->link->getModuleLink(
|
||||
'ps_eventbus',
|
||||
'apiThemes',
|
||||
[
|
||||
'job_id' => Tools::getValue('job_id', ''),
|
||||
'limit' => Tools::getValue('limit'),
|
||||
'full' => Tools::getValue('full'),
|
||||
],
|
||||
null,
|
||||
null,
|
||||
$this->context->shop->id
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
28
modules/ps_accounts/controllers/front/index.php
Normal file
28
modules/ps_accounts/controllers/front/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
28
modules/ps_accounts/controllers/index.php
Normal file
28
modules/ps_accounts/controllers/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
BIN
modules/ps_accounts/doc/healthy.png
Normal file
BIN
modules/ps_accounts/doc/healthy.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
28
modules/ps_accounts/doc/index.php
Normal file
28
modules/ps_accounts/doc/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
10
modules/ps_accounts/docker-compose.override.yml.dist
Normal file
10
modules/ps_accounts/docker-compose.override.yml.dist
Normal file
@@ -0,0 +1,10 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
ps_account_web:
|
||||
ports:
|
||||
- 80:80
|
||||
|
||||
ps_account_db:
|
||||
ports:
|
||||
- 3306:3306
|
||||
28
modules/ps_accounts/index.php
Normal file
28
modules/ps_accounts/index.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
BIN
modules/ps_accounts/logo.png
Normal file
BIN
modules/ps_accounts/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.5 KiB |
8
modules/ps_accounts/phpunit.xml
Normal file
8
modules/ps_accounts/phpunit.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit bootstrap="tests/bootstrap.php" colors="true" stopOnFailure="false">
|
||||
<testsuites>
|
||||
<testsuite name="Ps account Tests">
|
||||
<directory suffix="Test.php">./tests/php</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user