Compare commits
32 Commits
f3765a041e
...
1c1ce6ccff
| Author | SHA1 | Date | |
|---|---|---|---|
| 1c1ce6ccff | |||
| eba9671e1b | |||
| 2a95a8d4d2 | |||
| 92e9b32e2a | |||
| 241eda0a7e | |||
| 8e4c9fb0f5 | |||
| 003ac3acb3 | |||
| 5e47c08ac9 | |||
| 7f45a3b6cb | |||
| ff61596e56 | |||
| b837304722 | |||
| 117056310b | |||
| 1c939d5cad | |||
| 300b4d99ee | |||
| bddb47d984 | |||
| 771b94658e | |||
| b70f389413 | |||
| 66aeeff584 | |||
| a3c5145d7a | |||
| 35a2126697 | |||
| 940080851d | |||
| d3d2d5ad77 | |||
| 063af345be | |||
| 8559d51135 | |||
| 6618539096 | |||
| cf6f9db74f | |||
| 420e4e0af1 | |||
| 208dd29d71 | |||
| f4c71b06c1 | |||
| f319bf70e2 | |||
| d5d211a9e9 | |||
| 5c0d050d24 |
12
.github/workflows/php.yml
vendored
12
.github/workflows/php.yml
vendored
@ -14,11 +14,11 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
operating-system: ['ubuntu-latest']
|
operating-system: ['ubuntu-latest']
|
||||||
php-versions: ['8.1', '8.0','7.4']
|
php-versions: ['8.4','8.3','8.2','8.1', '8.0','7.4']
|
||||||
|
|
||||||
services:
|
services:
|
||||||
mariadb:
|
mariadb:
|
||||||
image: mariadb:10
|
image: mariadb:lts
|
||||||
ports:
|
ports:
|
||||||
- 3306:3306
|
- 3306:3306
|
||||||
env:
|
env:
|
||||||
@ -26,7 +26,7 @@ jobs:
|
|||||||
MYSQL_PASSWORD: password
|
MYSQL_PASSWORD: password
|
||||||
MYSQL_DATABASE: yii2-usuario-test
|
MYSQL_DATABASE: yii2-usuario-test
|
||||||
MYSQL_ROOT_PASSWORD: password
|
MYSQL_ROOT_PASSWORD: password
|
||||||
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
|
options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval=5s --health-timeout=5s --health-retries=3
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ jobs:
|
|||||||
ini-values: post_max_size=256M, max_execution_time=180
|
ini-values: post_max_size=256M, max_execution_time=180
|
||||||
coverage: xdebug
|
coverage: xdebug
|
||||||
|
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
|
||||||
- name: Verify MariaDB connection
|
- name: Verify MariaDB connection
|
||||||
@ -52,7 +52,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Cache Composer packages
|
- name: Cache Composer packages
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: vendor
|
path: vendor
|
||||||
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
|
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
|
||||||
@ -76,7 +76,7 @@ jobs:
|
|||||||
run: vendor/bin/phpstan analyse
|
run: vendor/bin/phpstan analyse
|
||||||
|
|
||||||
- name: Archive failed tests artifacts - test output & log
|
- name: Archive failed tests artifacts - test output & log
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v4
|
||||||
if: failure()
|
if: failure()
|
||||||
with:
|
with:
|
||||||
name: test-outputs-php-${{ matrix.php-versions }}
|
name: test-outputs-php-${{ matrix.php-versions }}
|
||||||
|
|||||||
@ -5,6 +5,12 @@
|
|||||||
- Enh: Changed exception thrown in PasswordRecoveryService from `RuntimeException` to `NotFoundException`. (eseperio)
|
- Enh: Changed exception thrown in PasswordRecoveryService from `RuntimeException` to `NotFoundException`. (eseperio)
|
||||||
- New #553: created Da\User\AuthClient\Microsoft365 auth client (edegaudenzi)
|
- New #553: created Da\User\AuthClient\Microsoft365 auth client (edegaudenzi)
|
||||||
- Ehh: Added SecurityHelper to the Bootstrap classMap
|
- Ehh: Added SecurityHelper to the Bootstrap classMap
|
||||||
|
- Fix #546: The profile/show page must not be visible by default, implement configurable policy (TonisOrmisson)
|
||||||
|
- Fix #397: No more fatal Exceptions when connecting to already taken Social Network (edegaudenzi)
|
||||||
|
- Ehh: Added option to pre-fill recovery email via url parameter (TonisOrmisson)
|
||||||
|
- Ehh: Fixed pretty-url rules not initialized for console apps (TonisOrmisson)
|
||||||
|
- Fix #572: Correctly positioned the 'Disconnect' button in networks view (edegaudenzi)
|
||||||
|
- Ehh: updated Italian (it) translation (edegaudenzi)
|
||||||
|
|
||||||
## 1.6.3 Mar 18th, 2024
|
## 1.6.3 Mar 18th, 2024
|
||||||
|
|
||||||
@ -12,7 +18,8 @@
|
|||||||
- Enh: Keycloak auth client (e.luhr)
|
- Enh: Keycloak auth client (e.luhr)
|
||||||
- Fix: Social Network Auth (eluhr)
|
- Fix: Social Network Auth (eluhr)
|
||||||
- Enh #532: /user/registration/register now shows form validation errors
|
- Enh #532: /user/registration/register now shows form validation errors
|
||||||
- Enh: Allow/suggest new v3 releases of 2amigos 2fa dependencies: 2fa-library, qrcode-library (TonisOrmisson)
|
- Enh: Allow/suggest new v3 releases of 2amigos 2fa dependencies: 2fa-library, qrcode-library (TonisOrmisson)
|
||||||
|
- Ehh: Added all the classes to the Bootstrap.php classMap
|
||||||
- Enh: Added option to disable viewing any other user's profile for non-admin users (TonisOrmisson)
|
- Enh: Added option to disable viewing any other user's profile for non-admin users (TonisOrmisson)
|
||||||
- Ehn: updated Estonian (et) translation by (TonisOrmisson)
|
- Ehn: updated Estonian (et) translation by (TonisOrmisson)
|
||||||
- Ehn: use recaptcha.net instead of google.com (Eseperio)
|
- Ehn: use recaptcha.net instead of google.com (Eseperio)
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "2amigos/yii2-usuario",
|
"name": "pcrt/yii2-usuario",
|
||||||
"description": "Highly customizable and extensible user management, authentication, and authorization Yii2 extension",
|
"description": "Highly customizable and extensible user management, authentication, and authorization Yii2 extension",
|
||||||
"type": "yii2-extension",
|
"type": "yii2-extension",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
@ -41,7 +41,7 @@
|
|||||||
"prefer-stable": true,
|
"prefer-stable": true,
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.5",
|
"php": ">=5.5",
|
||||||
"2amigos/yii2-selectize-widget": "^1.1",
|
"pcrt/yii2-select2": "^1.0.6",
|
||||||
"yiisoft/yii2-authclient": "^2.1",
|
"yiisoft/yii2-authclient": "^2.1",
|
||||||
"yiisoft/yii2-httpclient": "^2.0",
|
"yiisoft/yii2-httpclient": "^2.0",
|
||||||
"yiisoft/yii2-bootstrap": "^2.0",
|
"yiisoft/yii2-bootstrap": "^2.0",
|
||||||
@ -70,12 +70,12 @@
|
|||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Da\\User\\": "./src/User"
|
"pcrt\\User\\": "./src/User"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Da\\User\\": "./src/User"
|
"pcrt\\User\\": "./src/User"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
@ -97,7 +97,7 @@
|
|||||||
"dektrium/yii2-user": "*"
|
"dektrium/yii2-user": "*"
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"bootstrap": "Da\\User\\Bootstrap"
|
"bootstrap": "pcrt\\User\\Bootstrap"
|
||||||
},
|
},
|
||||||
"repositories": [
|
"repositories": [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -241,6 +241,15 @@ simple backends with static administrators that won't change throughout time.
|
|||||||
|
|
||||||
Configures the permission name for `administrators`. See [AuthHelper](../../src/User/Helper/AuthHelper.php).
|
Configures the permission name for `administrators`. See [AuthHelper](../../src/User/Helper/AuthHelper.php).
|
||||||
|
|
||||||
|
#### profileVisibility (type: `integer`, default:`0` (ProfileController::PROFILE_VISIBILITY_OWNER))
|
||||||
|
|
||||||
|
Configures to whom users 'profile/show' (public profile) page is shown. Constant values are defined in
|
||||||
|
[ProfileController](../../src/User/Controller/ProfileController.php) as constants. The visibility levels are:
|
||||||
|
- `0` (ProfileController::PROFILE_VISIBILITY_OWNER): The users profile page is shown ONLY to user itself, the owner of the profile.
|
||||||
|
- `1` (ProfileController::PROFILE_VISIBILITY_ADMIN): The users profile is shown ONLY to user itself (owner) AND users defined by module as admins.
|
||||||
|
- `2` (ProfileController::PROFILE_VISIBILITY_USERS): Any users profile page is shown to any other non-guest user.
|
||||||
|
- `3` (ProfileController::PROFILE_VISIBILITY_PUBLIC): Any user profile views are globally public and visible to anyone (including guests).
|
||||||
|
|
||||||
#### prefix (type: `string`, default: `user`)
|
#### prefix (type: `string`, default: `user`)
|
||||||
|
|
||||||
Configures the URL prefix for the module.
|
Configures the URL prefix for the module.
|
||||||
@ -313,11 +322,6 @@ Set to `true` to restrict user assignments to roles only.
|
|||||||
|
|
||||||
If `true` registration and last login IPs are not logged into users table, instead a dummy 127.0.0.1 is used
|
If `true` registration and last login IPs are not logged into users table, instead a dummy 127.0.0.1 is used
|
||||||
|
|
||||||
|
|
||||||
#### disableProfileViewsForRegularUsers (type: `boolean`, default: `false`)
|
|
||||||
|
|
||||||
If `true` only admin users have access to view any other user's profile. By default any user can see any other users public profile page.
|
|
||||||
|
|
||||||
#### minPasswordRequirements (type: `array`, default: `['lower' => 1, 'digit' => 1, 'upper' => 1]`)
|
#### minPasswordRequirements (type: `array`, default: `['lower' => 1, 'digit' => 1, 'upper' => 1]`)
|
||||||
|
|
||||||
Minimum requirements when a new password is automatically generated.
|
Minimum requirements when a new password is automatically generated.
|
||||||
|
|||||||
@ -9,10 +9,10 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\AuthClient;
|
namespace pcrt\User\AuthClient;
|
||||||
|
|
||||||
use Da\User\Contracts\AuthClientInterface;
|
use pcrt\User\Contracts\AuthClientInterface;
|
||||||
use Da\User\Traits\AuthClientUserIdTrait;
|
use pcrt\User\Traits\AuthClientUserIdTrait;
|
||||||
use yii\authclient\clients\Facebook as BaseFacebook;
|
use yii\authclient\clients\Facebook as BaseFacebook;
|
||||||
|
|
||||||
class Facebook extends BaseFacebook implements AuthClientInterface
|
class Facebook extends BaseFacebook implements AuthClientInterface
|
||||||
|
|||||||
@ -9,10 +9,10 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\AuthClient;
|
namespace pcrt\User\AuthClient;
|
||||||
|
|
||||||
use Da\User\Contracts\AuthClientInterface;
|
use pcrt\User\Contracts\AuthClientInterface;
|
||||||
use Da\User\Traits\AuthClientUserIdTrait;
|
use pcrt\User\Traits\AuthClientUserIdTrait;
|
||||||
use yii\authclient\clients\GitHub as BaseGitHub;
|
use yii\authclient\clients\GitHub as BaseGitHub;
|
||||||
|
|
||||||
class GitHub extends BaseGitHub implements AuthClientInterface
|
class GitHub extends BaseGitHub implements AuthClientInterface
|
||||||
|
|||||||
@ -9,10 +9,10 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\AuthClient;
|
namespace pcrt\User\AuthClient;
|
||||||
|
|
||||||
use Da\User\Contracts\AuthClientInterface;
|
use pcrt\User\Contracts\AuthClientInterface;
|
||||||
use Da\User\Traits\AuthClientUserIdTrait;
|
use pcrt\User\Traits\AuthClientUserIdTrait;
|
||||||
use yii\authclient\clients\Google as BaseGoogle;
|
use yii\authclient\clients\Google as BaseGoogle;
|
||||||
|
|
||||||
class Google extends BaseGoogle implements AuthClientInterface
|
class Google extends BaseGoogle implements AuthClientInterface
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Da\User\AuthClient;
|
namespace pcrt\User\AuthClient;
|
||||||
|
|
||||||
use Da\User\Contracts\AuthClientInterface;
|
use pcrt\User\Contracts\AuthClientInterface;
|
||||||
use yii\authclient\OpenIdConnect;
|
use yii\authclient\OpenIdConnect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -9,10 +9,10 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\AuthClient;
|
namespace pcrt\User\AuthClient;
|
||||||
|
|
||||||
use Da\User\Contracts\AuthClientInterface;
|
use pcrt\User\Contracts\AuthClientInterface;
|
||||||
use Da\User\Traits\AuthClientUserIdTrait;
|
use pcrt\User\Traits\AuthClientUserIdTrait;
|
||||||
use yii\authclient\clients\LinkedIn as BaseLinkedIn;
|
use yii\authclient\clients\LinkedIn as BaseLinkedIn;
|
||||||
|
|
||||||
class LinkedIn extends BaseLinkedIn implements AuthClientInterface
|
class LinkedIn extends BaseLinkedIn implements AuthClientInterface
|
||||||
|
|||||||
@ -9,10 +9,10 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\AuthClient;
|
namespace pcrt\User\AuthClient;
|
||||||
|
|
||||||
use Da\User\Contracts\AuthClientInterface;
|
use pcrt\User\Contracts\AuthClientInterface;
|
||||||
use Da\User\Traits\AuthClientUserIdTrait;
|
use pcrt\User\Traits\AuthClientUserIdTrait;
|
||||||
use yii\authclient\OAuth2;
|
use yii\authclient\OAuth2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -9,10 +9,10 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\AuthClient;
|
namespace pcrt\User\AuthClient;
|
||||||
|
|
||||||
use Da\User\Contracts\AuthClientInterface;
|
use pcrt\User\Contracts\AuthClientInterface;
|
||||||
use Da\User\Traits\AuthClientUserIdTrait;
|
use pcrt\User\Traits\AuthClientUserIdTrait;
|
||||||
use yii\authclient\clients\Twitter as BaseTwitter;
|
use yii\authclient\clients\Twitter as BaseTwitter;
|
||||||
|
|
||||||
class Twitter extends BaseTwitter implements AuthClientInterface
|
class Twitter extends BaseTwitter implements AuthClientInterface
|
||||||
|
|||||||
@ -9,10 +9,10 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\AuthClient;
|
namespace pcrt\User\AuthClient;
|
||||||
|
|
||||||
use Da\User\Contracts\AuthClientInterface;
|
use pcrt\User\Contracts\AuthClientInterface;
|
||||||
use Da\User\Traits\AuthClientUserIdTrait;
|
use pcrt\User\Traits\AuthClientUserIdTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\authclient\clients\VKontakte as BaseVKontakte;
|
use yii\authclient\clients\VKontakte as BaseVKontakte;
|
||||||
|
|
||||||
|
|||||||
@ -9,10 +9,10 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\AuthClient;
|
namespace pcrt\User\AuthClient;
|
||||||
|
|
||||||
use Da\User\Contracts\AuthClientInterface;
|
use pcrt\User\Contracts\AuthClientInterface;
|
||||||
use Da\User\Traits\AuthClientUserIdTrait;
|
use pcrt\User\Traits\AuthClientUserIdTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\authclient\clients\Yandex as BaseYandex;
|
use yii\authclient\clients\Yandex as BaseYandex;
|
||||||
|
|
||||||
|
|||||||
@ -9,16 +9,16 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User;
|
namespace pcrt\User;
|
||||||
|
|
||||||
use Da\User\Component\AuthDbManagerComponent;
|
use pcrt\User\Component\AuthDbManagerComponent;
|
||||||
use Da\User\Contracts\AuthManagerInterface;
|
use pcrt\User\Contracts\AuthManagerInterface;
|
||||||
use Da\User\Controller\SecurityController;
|
use pcrt\User\Controller\SecurityController;
|
||||||
use Da\User\Event\FormEvent;
|
use pcrt\User\Event\FormEvent;
|
||||||
use Da\User\Helper\ClassMapHelper;
|
use pcrt\User\Helper\ClassMapHelper;
|
||||||
use Da\User\Model\SessionHistory;
|
use pcrt\User\Model\SessionHistory;
|
||||||
use Da\User\Model\User;
|
use pcrt\User\Model\User;
|
||||||
use Da\User\Search\SessionHistorySearch;
|
use pcrt\User\Search\SessionHistorySearch;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\authclient\Collection;
|
use yii\authclient\Collection;
|
||||||
use yii\base\Application;
|
use yii\base\Application;
|
||||||
@ -30,6 +30,7 @@ use yii\console\Application as ConsoleApplication;
|
|||||||
use yii\helpers\ArrayHelper;
|
use yii\helpers\ArrayHelper;
|
||||||
use yii\i18n\PhpMessageSource;
|
use yii\i18n\PhpMessageSource;
|
||||||
use yii\web\Application as WebApplication;
|
use yii\web\Application as WebApplication;
|
||||||
|
use yii\web\UrlManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bootstrap class of the yii2-usuario extension. Configures container services, initializes translations,
|
* Bootstrap class of the yii2-usuario extension. Configures container services, initializes translations,
|
||||||
@ -49,10 +50,10 @@ class Bootstrap implements BootstrapInterface
|
|||||||
$this->initTranslations($app);
|
$this->initTranslations($app);
|
||||||
$this->initContainer($app, $map);
|
$this->initContainer($app, $map);
|
||||||
$this->initMailServiceConfiguration($app, $app->getModule('user'));
|
$this->initMailServiceConfiguration($app, $app->getModule('user'));
|
||||||
|
$this->initUrlRoutes($app);
|
||||||
|
|
||||||
if ($app instanceof WebApplication) {
|
if ($app instanceof WebApplication) {
|
||||||
$this->initControllerNamespace($app);
|
$this->initControllerNamespace($app);
|
||||||
$this->initUrlRoutes($app);
|
|
||||||
$this->initUrlRestRoutes($app);
|
$this->initUrlRestRoutes($app);
|
||||||
$this->initAuthCollection($app);
|
$this->initAuthCollection($app);
|
||||||
$this->initAuthManager($app);
|
$this->initAuthManager($app);
|
||||||
@ -134,7 +135,7 @@ class Bootstrap implements BootstrapInterface
|
|||||||
$modelClassMap[$class] = $model;
|
$modelClassMap[$class] = $model;
|
||||||
if (in_array($name, ['User', 'Profile', 'Token', 'SocialNetworkAccount', 'SessionHistory'])) {
|
if (in_array($name, ['User', 'Profile', 'Token', 'SocialNetworkAccount', 'SessionHistory'])) {
|
||||||
$di->set(
|
$di->set(
|
||||||
"Da\\User\\Query\\{$name}Query",
|
"pcrt\\User\\Query\\{$name}Query",
|
||||||
function () use ($model) {
|
function () use ($model) {
|
||||||
return $model::find();
|
return $model::find();
|
||||||
}
|
}
|
||||||
@ -170,13 +171,13 @@ class Bootstrap implements BootstrapInterface
|
|||||||
$defaultTwoFactorAuthenticationValidators =
|
$defaultTwoFactorAuthenticationValidators =
|
||||||
[
|
[
|
||||||
'google-authenticator' => [
|
'google-authenticator' => [
|
||||||
'class' => \Da\User\Validator\TwoFactorCodeValidator::class,
|
'class' => \pcrt\User\Validator\TwoFactorCodeValidator::class,
|
||||||
'description' => Yii::t('usuario', 'Google Authenticator'),
|
'description' => Yii::t('usuario', 'Google Authenticator'),
|
||||||
'configurationUrl' => 'user/settings/two-factor',
|
'configurationUrl' => 'user/settings/two-factor',
|
||||||
'enabled' => true
|
'enabled' => true
|
||||||
],
|
],
|
||||||
'email' => [
|
'email' => [
|
||||||
'class' => \Da\User\Validator\TwoFactorEmailValidator::class,
|
'class' => \pcrt\User\Validator\TwoFactorEmailValidator::class,
|
||||||
'description' => Yii::t('usuario', 'Email'),
|
'description' => Yii::t('usuario', 'Email'),
|
||||||
'configurationUrl' => 'user/settings/two-factor-email',
|
'configurationUrl' => 'user/settings/two-factor-email',
|
||||||
// Time duration of the code in seconds
|
// Time duration of the code in seconds
|
||||||
@ -184,7 +185,7 @@ class Bootstrap implements BootstrapInterface
|
|||||||
'enabled' => true
|
'enabled' => true
|
||||||
],
|
],
|
||||||
'sms' => [
|
'sms' => [
|
||||||
'class' => \Da\User\Validator\TwoFactorTextMessageValidator::class,
|
'class' => \pcrt\User\Validator\TwoFactorTextMessageValidator::class,
|
||||||
'description' => Yii::t('usuario', 'Text message'),
|
'description' => Yii::t('usuario', 'Text message'),
|
||||||
'configurationUrl' => 'user/settings/two-factor-sms',
|
'configurationUrl' => 'user/settings/two-factor-sms',
|
||||||
// component for sending sms
|
// component for sending sms
|
||||||
@ -256,11 +257,11 @@ class Bootstrap implements BootstrapInterface
|
|||||||
/**
|
/**
|
||||||
* Initializes web url routes (rules in Yii2).
|
* Initializes web url routes (rules in Yii2).
|
||||||
*
|
*
|
||||||
* @param WebApplication $app
|
* @param Application $app
|
||||||
*
|
*
|
||||||
* @throws InvalidConfigException
|
* @throws InvalidConfigException
|
||||||
*/
|
*/
|
||||||
protected function initUrlRoutes(WebApplication $app)
|
protected function initUrlRoutes(Application $app)
|
||||||
{
|
{
|
||||||
/** @var $module Module */
|
/** @var $module Module */
|
||||||
$module = $app->getModule('user');
|
$module = $app->getModule('user');
|
||||||
@ -274,8 +275,13 @@ class Bootstrap implements BootstrapInterface
|
|||||||
$config['routePrefix'] = 'user';
|
$config['routePrefix'] = 'user';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$urlManager = $app->getUrlManager();
|
||||||
|
if(!($urlManager instanceof UrlManager)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$rule = Yii::createObject($config);
|
$rule = Yii::createObject($config);
|
||||||
$app->getUrlManager()->addRules([$rule], false);
|
$urlManager->addRules([$rule], false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -367,31 +373,31 @@ class Bootstrap implements BootstrapInterface
|
|||||||
|
|
||||||
$defaults = [
|
$defaults = [
|
||||||
// --- models
|
// --- models
|
||||||
'User' => 'Da\User\Model\User',
|
'User' => 'pcrt\User\Model\User',
|
||||||
'SocialNetworkAccount' => 'Da\User\Model\SocialNetworkAccount',
|
'SocialNetworkAccount' => 'pcrt\User\Model\SocialNetworkAccount',
|
||||||
'Profile' => 'Da\User\Model\Profile',
|
'Profile' => 'pcrt\User\Model\Profile',
|
||||||
'Token' => 'Da\User\Model\Token',
|
'Token' => 'pcrt\User\Model\Token',
|
||||||
'Assignment' => 'Da\User\Model\Assignment',
|
'Assignment' => 'pcrt\User\Model\Assignment',
|
||||||
'Permission' => 'Da\User\Model\Permission',
|
'Permission' => 'pcrt\User\Model\Permission',
|
||||||
'Role' => 'Da\User\Model\Role',
|
'Role' => 'pcrt\User\Model\Role',
|
||||||
'SessionHistory' => SessionHistory::class,
|
'SessionHistory' => SessionHistory::class,
|
||||||
// --- search
|
// --- search
|
||||||
'UserSearch' => 'Da\User\Search\UserSearch',
|
'UserSearch' => 'pcrt\User\Search\UserSearch',
|
||||||
'PermissionSearch' => 'Da\User\Search\PermissionSearch',
|
'PermissionSearch' => 'pcrt\User\Search\PermissionSearch',
|
||||||
'RoleSearch' => 'Da\User\Search\RoleSearch',
|
'RoleSearch' => 'pcrt\User\Search\RoleSearch',
|
||||||
'SessionHistorySearch' => SessionHistorySearch::class,
|
'SessionHistorySearch' => SessionHistorySearch::class,
|
||||||
// --- forms
|
// --- forms
|
||||||
'RegistrationForm' => 'Da\User\Form\RegistrationForm',
|
'RegistrationForm' => 'pcrt\User\Form\RegistrationForm',
|
||||||
'ResendForm' => 'Da\User\Form\ResendForm',
|
'ResendForm' => 'pcrt\User\Form\ResendForm',
|
||||||
'LoginForm' => 'Da\User\Form\LoginForm',
|
'LoginForm' => 'pcrt\User\Form\LoginForm',
|
||||||
'SettingsForm' => 'Da\User\Form\SettingsForm',
|
'SettingsForm' => 'pcrt\User\Form\SettingsForm',
|
||||||
'RecoveryForm' => 'Da\User\Form\RecoveryForm',
|
'RecoveryForm' => 'pcrt\User\Form\RecoveryForm',
|
||||||
// --- services
|
// --- services
|
||||||
'MailService' => 'Da\User\Service\MailService',
|
'MailService' => 'pcrt\User\Service\MailService',
|
||||||
];
|
];
|
||||||
|
|
||||||
$routes = [
|
$routes = [
|
||||||
'Da\User\Model' => [
|
'pcrt\User\Model' => [
|
||||||
'User',
|
'User',
|
||||||
'SocialNetworkAccount',
|
'SocialNetworkAccount',
|
||||||
'Profile',
|
'Profile',
|
||||||
@ -399,26 +405,54 @@ class Bootstrap implements BootstrapInterface
|
|||||||
'Assignment',
|
'Assignment',
|
||||||
'Permission',
|
'Permission',
|
||||||
'Role',
|
'Role',
|
||||||
'SessionHistory'
|
'SessionHistory',
|
||||||
|
'AbstractAuthItem',
|
||||||
|
'Rule',
|
||||||
],
|
],
|
||||||
'Da\User\Search' => [
|
'pcrt\User\Search' => [
|
||||||
'UserSearch',
|
'UserSearch',
|
||||||
'PermissionSearch',
|
'PermissionSearch',
|
||||||
'RoleSearch',
|
'RoleSearch',
|
||||||
'SessionHistorySearch',
|
'SessionHistorySearch',
|
||||||
|
'RuleSearch',
|
||||||
|
'AbstractAuthItemSearch',
|
||||||
],
|
],
|
||||||
'Da\User\Form' => [
|
'pcrt\User\Form' => [
|
||||||
'RegistrationForm',
|
'RegistrationForm',
|
||||||
'ResendForm',
|
'ResendForm',
|
||||||
'LoginForm',
|
'LoginForm',
|
||||||
'SettingsForm',
|
'SettingsForm',
|
||||||
'RecoveryForm',
|
'RecoveryForm',
|
||||||
|
'GdprDeleteForm',
|
||||||
],
|
],
|
||||||
'Da\User\Service' => [
|
'pcrt\User\Service' => [
|
||||||
|
'AccountConfirmationService',
|
||||||
|
'AuthItemEditionService',
|
||||||
|
'AuthRuleEditionService',
|
||||||
|
'EmailChangeService',
|
||||||
'MailService',
|
'MailService',
|
||||||
|
'PasswordExpireService',
|
||||||
|
'PasswordRecoveryService',
|
||||||
|
'ResendConfirmationService',
|
||||||
|
'ResetPasswordService',
|
||||||
|
'SocialNetworkAccountConnectService',
|
||||||
|
'SocialNetworkAuthenticateService',
|
||||||
|
'SwitchIdentityService',
|
||||||
|
'TwoFactorEmailCodeGeneratorService',
|
||||||
|
'TwoFactorQrCodeUriGeneratorService',
|
||||||
|
'TwoFactorSmsCodeGeneratorService',
|
||||||
|
'UpdateAuthAssignmentsService',
|
||||||
|
'UserBlockService',
|
||||||
|
'UserConfirmationService',
|
||||||
|
'UserCreateService',
|
||||||
|
'UserRegisterService',
|
||||||
],
|
],
|
||||||
'Da\User\Helper' => [
|
'pcrt\User\Helper' => [
|
||||||
|
'AuthHelper',
|
||||||
|
'ClassMapHelper',
|
||||||
|
'MigrationHelper',
|
||||||
'SecurityHelper',
|
'SecurityHelper',
|
||||||
|
'TimezoneHelper',
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@ -9,11 +9,11 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Command;
|
namespace pcrt\User\Command;
|
||||||
|
|
||||||
use Da\User\Query\UserQuery;
|
use pcrt\User\Query\UserQuery;
|
||||||
use Da\User\Service\UserConfirmationService;
|
use pcrt\User\Service\UserConfirmationService;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
use pcrt\User\Traits\ContainerAwareTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Module;
|
use yii\base\Module;
|
||||||
use yii\console\Controller;
|
use yii\console\Controller;
|
||||||
|
|||||||
@ -9,12 +9,12 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Command;
|
namespace pcrt\User\Command;
|
||||||
|
|
||||||
use Da\User\Factory\MailFactory;
|
use pcrt\User\Factory\MailFactory;
|
||||||
use Da\User\Model\User;
|
use pcrt\User\Model\User;
|
||||||
use Da\User\Service\UserCreateService;
|
use pcrt\User\Service\UserCreateService;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
use pcrt\User\Traits\ContainerAwareTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\console\Controller;
|
use yii\console\Controller;
|
||||||
use yii\helpers\Console;
|
use yii\helpers\Console;
|
||||||
|
|||||||
@ -9,9 +9,9 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Command;
|
namespace pcrt\User\Command;
|
||||||
|
|
||||||
use Da\User\Query\UserQuery;
|
use pcrt\User\Query\UserQuery;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Module;
|
use yii\base\Module;
|
||||||
|
|||||||
@ -9,12 +9,12 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Command;
|
namespace pcrt\User\Command;
|
||||||
|
|
||||||
use Da\User\Model\User;
|
use pcrt\User\Model\User;
|
||||||
use Da\User\Query\UserQuery;
|
use pcrt\User\Query\UserQuery;
|
||||||
use Da\User\Service\ResetPasswordService;
|
use pcrt\User\Service\ResetPasswordService;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
use pcrt\User\Traits\ContainerAwareTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\InvalidConfigException;
|
use yii\base\InvalidConfigException;
|
||||||
use yii\base\Module;
|
use yii\base\Module;
|
||||||
|
|||||||
@ -9,9 +9,9 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Component;
|
namespace pcrt\User\Component;
|
||||||
|
|
||||||
use Da\User\Contracts\AuthManagerInterface;
|
use pcrt\User\Contracts\AuthManagerInterface;
|
||||||
use yii\base\InvalidArgumentException;
|
use yii\base\InvalidArgumentException;
|
||||||
use yii\db\Expression;
|
use yii\db\Expression;
|
||||||
use yii\db\Query;
|
use yii\db\Query;
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Component;
|
namespace pcrt\User\Component;
|
||||||
|
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Component;
|
use yii\base\Component;
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Contracts;
|
namespace pcrt\User\Contracts;
|
||||||
|
|
||||||
use yii\authclient\ClientInterface;
|
use yii\authclient\ClientInterface;
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Contracts;
|
namespace pcrt\User\Contracts;
|
||||||
|
|
||||||
use yii\rbac\ManagerInterface;
|
use yii\rbac\ManagerInterface;
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Contracts;
|
namespace pcrt\User\Contracts;
|
||||||
|
|
||||||
interface MailChangeStrategyInterface extends StrategyInterface
|
interface MailChangeStrategyInterface extends StrategyInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Contracts;
|
namespace pcrt\User\Contracts;
|
||||||
|
|
||||||
interface ServiceInterface
|
interface ServiceInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Contracts;
|
namespace pcrt\User\Contracts;
|
||||||
|
|
||||||
interface StrategyInterface
|
interface StrategyInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Contracts;
|
namespace pcrt\User\Contracts;
|
||||||
|
|
||||||
interface ValidatorInterface
|
interface ValidatorInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@ -9,15 +9,15 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Controller;
|
namespace pcrt\User\Controller;
|
||||||
|
|
||||||
use Da\User\Filter\AccessRuleFilter;
|
use pcrt\User\Filter\AccessRuleFilter;
|
||||||
use Da\User\Helper\AuthHelper;
|
use pcrt\User\Helper\AuthHelper;
|
||||||
use Da\User\Model\AbstractAuthItem;
|
use pcrt\User\Model\AbstractAuthItem;
|
||||||
use Da\User\Module;
|
use pcrt\User\Module;
|
||||||
use Da\User\Service\AuthItemEditionService;
|
use pcrt\User\Service\AuthItemEditionService;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
use pcrt\User\Traits\ContainerAwareTrait;
|
||||||
use Da\User\Validator\AjaxRequestModelValidator;
|
use pcrt\User\Validator\AjaxRequestModelValidator;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\filters\AccessControl;
|
use yii\filters\AccessControl;
|
||||||
use yii\web\Controller;
|
use yii\web\Controller;
|
||||||
|
|||||||
@ -9,26 +9,26 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Controller;
|
namespace pcrt\User\Controller;
|
||||||
|
|
||||||
use Da\User\Event\UserEvent;
|
use pcrt\User\Event\UserEvent;
|
||||||
use Da\User\Factory\MailFactory;
|
use pcrt\User\Factory\MailFactory;
|
||||||
use Da\User\Filter\AccessRuleFilter;
|
use pcrt\User\Filter\AccessRuleFilter;
|
||||||
use Da\User\Model\Profile;
|
use pcrt\User\Model\Profile;
|
||||||
use Da\User\Model\User;
|
use pcrt\User\Model\User;
|
||||||
use Da\User\Query\UserQuery;
|
use pcrt\User\Query\UserQuery;
|
||||||
use Da\User\Search\SessionHistorySearch;
|
use pcrt\User\Search\SessionHistorySearch;
|
||||||
use Da\User\Search\UserSearch;
|
use pcrt\User\Search\UserSearch;
|
||||||
use Da\User\Service\PasswordExpireService;
|
use pcrt\User\Service\PasswordExpireService;
|
||||||
use Da\User\Service\PasswordRecoveryService;
|
use pcrt\User\Service\PasswordRecoveryService;
|
||||||
use Da\User\Service\SessionHistory\TerminateUserSessionsService;
|
use pcrt\User\Service\SessionHistory\TerminateUserSessionsService;
|
||||||
use Da\User\Service\SwitchIdentityService;
|
use pcrt\User\Service\SwitchIdentityService;
|
||||||
use Da\User\Service\UserBlockService;
|
use pcrt\User\Service\UserBlockService;
|
||||||
use Da\User\Service\UserConfirmationService;
|
use pcrt\User\Service\UserConfirmationService;
|
||||||
use Da\User\Service\UserCreateService;
|
use pcrt\User\Service\UserCreateService;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
use pcrt\User\Traits\ContainerAwareTrait;
|
||||||
use Da\User\Traits\ModuleAwareTrait;
|
use pcrt\User\Traits\ModuleAwareTrait;
|
||||||
use Da\User\Validator\AjaxRequestModelValidator;
|
use pcrt\User\Validator\AjaxRequestModelValidator;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Module;
|
use yii\base\Module;
|
||||||
use yii\db\ActiveRecord;
|
use yii\db\ActiveRecord;
|
||||||
@ -144,6 +144,8 @@ class AdminController extends Controller
|
|||||||
$this->make(AjaxRequestModelValidator::class, [$user])->validate();
|
$this->make(AjaxRequestModelValidator::class, [$user])->validate();
|
||||||
|
|
||||||
if ($user->load(Yii::$app->request->post()) && $user->validate()) {
|
if ($user->load(Yii::$app->request->post()) && $user->validate()) {
|
||||||
|
$user->created_by = Yii::$app->user->getId() ?? null;
|
||||||
|
|
||||||
$this->trigger(UserEvent::EVENT_BEFORE_CREATE, $event);
|
$this->trigger(UserEvent::EVENT_BEFORE_CREATE, $event);
|
||||||
|
|
||||||
$mailService = MailFactory::makeWelcomeMailerService($user);
|
$mailService = MailFactory::makeWelcomeMailerService($user);
|
||||||
|
|||||||
@ -9,10 +9,10 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Controller;
|
namespace pcrt\User\Controller;
|
||||||
|
|
||||||
use Da\User\Model\Permission;
|
use pcrt\User\Model\Permission;
|
||||||
use Da\User\Search\PermissionSearch;
|
use pcrt\User\Search\PermissionSearch;
|
||||||
use yii\web\NotFoundHttpException;
|
use yii\web\NotFoundHttpException;
|
||||||
|
|
||||||
class PermissionController extends AbstractAuthItemController
|
class PermissionController extends AbstractAuthItemController
|
||||||
|
|||||||
@ -9,35 +9,90 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Controller;
|
namespace pcrt\User\Controller;
|
||||||
|
|
||||||
use Da\User\Model\User;
|
use pcrt\User\Contracts\MailChangeStrategyInterface;
|
||||||
use Da\User\Query\ProfileQuery;
|
use pcrt\User\Event\GdprEvent;
|
||||||
use Da\User\Traits\ModuleAwareTrait;
|
use pcrt\User\Event\ProfileEvent;
|
||||||
|
use pcrt\User\Event\SocialNetworkConnectEvent;
|
||||||
|
use pcrt\User\Event\UserEvent;
|
||||||
|
use pcrt\User\Form\GdprDeleteForm;
|
||||||
|
use pcrt\User\Form\SettingsForm;
|
||||||
|
use pcrt\User\Helper\SecurityHelper;
|
||||||
|
use pcrt\User\Model\Profile;
|
||||||
|
use pcrt\User\Model\SocialNetworkAccount;
|
||||||
|
use pcrt\User\Model\User;
|
||||||
|
use pcrt\User\Module;
|
||||||
|
use pcrt\User\Query\ProfileQuery;
|
||||||
|
use pcrt\User\Query\SocialNetworkAccountQuery;
|
||||||
|
use pcrt\User\Query\UserQuery;
|
||||||
|
use pcrt\User\Search\SessionHistorySearch;
|
||||||
|
use pcrt\User\Service\EmailChangeService;
|
||||||
|
use pcrt\User\Service\SessionHistory\TerminateUserSessionsService;
|
||||||
|
use pcrt\User\Service\TwoFactorEmailCodeGeneratorService;
|
||||||
|
use pcrt\User\Service\TwoFactorQrCodeUriGeneratorService;
|
||||||
|
use pcrt\User\Service\TwoFactorSmsCodeGeneratorService;
|
||||||
|
use pcrt\User\Traits\ContainerAwareTrait;
|
||||||
|
use pcrt\User\Traits\ModuleAwareTrait;
|
||||||
|
use pcrt\User\Validator\AjaxRequestModelValidator;
|
||||||
|
use pcrt\User\Validator\TwoFactorCodeValidator;
|
||||||
|
use pcrt\User\Validator\TwoFactorEmailValidator;
|
||||||
|
use pcrt\User\Validator\TwoFactorTextMessageValidator;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Module;
|
use yii\base\DynamicModel;
|
||||||
|
use yii\base\InvalidParamException;
|
||||||
use yii\filters\AccessControl;
|
use yii\filters\AccessControl;
|
||||||
|
use yii\filters\VerbFilter;
|
||||||
|
use yii\helpers\ArrayHelper;
|
||||||
use yii\web\Controller;
|
use yii\web\Controller;
|
||||||
use yii\web\ForbiddenHttpException;
|
use yii\web\ForbiddenHttpException;
|
||||||
use yii\web\NotFoundHttpException;
|
use yii\web\NotFoundHttpException;
|
||||||
|
use yii\web\Response;
|
||||||
|
|
||||||
class ProfileController extends Controller
|
class ProfileController extends Controller
|
||||||
{
|
{
|
||||||
|
use ContainerAwareTrait;
|
||||||
use ModuleAwareTrait;
|
use ModuleAwareTrait;
|
||||||
|
|
||||||
protected $profileQuery;
|
/** @var int will allow only profile owner */
|
||||||
|
const PROFILE_VISIBILITY_OWNER = 0;
|
||||||
|
/** @var int will allow profile owner and admin users */
|
||||||
|
const PROFILE_VISIBILITY_ADMIN = 1;
|
||||||
|
/** @var int will allow any logged-in users */
|
||||||
|
const PROFILE_VISIBILITY_USERS = 2;
|
||||||
|
/** @var int will allow anyone, including guests */
|
||||||
|
public const PROFILE_VISIBILITY_PUBLIC = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ProfileController constructor.
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @param string $id
|
|
||||||
* @param Module $module
|
|
||||||
* @param ProfileQuery $profileQuery
|
|
||||||
* @param array $config
|
|
||||||
*/
|
*/
|
||||||
public function __construct($id, Module $module, ProfileQuery $profileQuery, array $config = [])
|
public $defaultAction = 'profile';
|
||||||
{
|
|
||||||
|
protected $profileQuery;
|
||||||
|
protected $userQuery;
|
||||||
|
protected $socialNetworkAccountQuery;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SettingsController constructor.
|
||||||
|
*
|
||||||
|
* @param string $id
|
||||||
|
* @param Module $module
|
||||||
|
* @param ProfileQuery $profileQuery
|
||||||
|
* @param UserQuery $userQuery
|
||||||
|
* @param SocialNetworkAccountQuery $socialNetworkAccountQuery
|
||||||
|
* @param array $config
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
$id,
|
||||||
|
Module $module,
|
||||||
|
ProfileQuery $profileQuery,
|
||||||
|
UserQuery $userQuery,
|
||||||
|
SocialNetworkAccountQuery $socialNetworkAccountQuery,
|
||||||
|
array $config = []
|
||||||
|
) {
|
||||||
$this->profileQuery = $profileQuery;
|
$this->profileQuery = $profileQuery;
|
||||||
|
$this->userQuery = $userQuery;
|
||||||
|
$this->socialNetworkAccountQuery = $socialNetworkAccountQuery;
|
||||||
parent::__construct($id, $module, $config);
|
parent::__construct($id, $module, $config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,49 +102,559 @@ class ProfileController extends Controller
|
|||||||
public function behaviors()
|
public function behaviors()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
'verbs' => [
|
||||||
|
'class' => VerbFilter::class,
|
||||||
|
'actions' => [
|
||||||
|
'disconnect' => ['post'],
|
||||||
|
'delete' => ['post'],
|
||||||
|
'two-factor-disable' => ['post'],
|
||||||
|
'terminate-sessions' => ['post'],
|
||||||
|
],
|
||||||
|
],
|
||||||
'access' => [
|
'access' => [
|
||||||
'class' => AccessControl::class,
|
'class' => AccessControl::class,
|
||||||
'rules' => [
|
'rules' => [
|
||||||
[
|
[
|
||||||
'allow' => true,
|
'allow' => true,
|
||||||
'actions' => ['index'],
|
'actions' => [
|
||||||
|
'profile',
|
||||||
|
'account',
|
||||||
|
'export',
|
||||||
|
'networks',
|
||||||
|
'privacy',
|
||||||
|
'gdpr-consent',
|
||||||
|
'gdpr-delete',
|
||||||
|
'disconnect',
|
||||||
|
'delete',
|
||||||
|
'two-factor',
|
||||||
|
'two-factor-enable',
|
||||||
|
'two-factor-disable',
|
||||||
|
'two-factor-mobile-phone'
|
||||||
|
],
|
||||||
'roles' => ['@'],
|
'roles' => ['@'],
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'allow' => true,
|
'allow' => true,
|
||||||
'actions' => ['show'],
|
'actions' => ['confirm'],
|
||||||
'roles' => ['?', '@'],
|
'roles' => ['?', '@'],
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'allow' => $this->getModule()->enableSessionHistory,
|
||||||
|
'actions' => ['session-history', 'terminate-sessions'],
|
||||||
|
'roles' => ['@'],
|
||||||
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function actionIndex()
|
/**
|
||||||
|
* @throws \yii\base\InvalidConfigException
|
||||||
|
* @return string|Response
|
||||||
|
*/
|
||||||
|
public function actionProfile()
|
||||||
{
|
{
|
||||||
return $this->redirect(['show', 'id' => Yii::$app->user->getId()]);
|
$profile = $this->profileQuery->whereUserId(Yii::$app->user->identity->getId())->one();
|
||||||
}
|
|
||||||
|
|
||||||
public function actionShow($id)
|
|
||||||
{
|
|
||||||
$user = Yii::$app->user;
|
|
||||||
/** @var User $identity */
|
|
||||||
$identity = $user->getIdentity();
|
|
||||||
if($user->getId() != $id && $this->module->disableProfileViewsForRegularUsers && !$identity->getIsAdmin()) {
|
|
||||||
throw new ForbiddenHttpException();
|
|
||||||
}
|
|
||||||
|
|
||||||
$profile = $this->profileQuery->whereUserId($id)->one();
|
|
||||||
|
|
||||||
if ($profile === null) {
|
if ($profile === null) {
|
||||||
throw new NotFoundHttpException();
|
$profile = $this->make(Profile::class);
|
||||||
|
$profile->link('user', Yii::$app->user->identity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @var ProfileEvent $event
|
||||||
|
*/
|
||||||
|
$event = $this->make(ProfileEvent::class, [$profile]);
|
||||||
|
|
||||||
|
$this->make(AjaxRequestModelValidator::class, [$profile])->validate();
|
||||||
|
|
||||||
|
if ($profile->load(Yii::$app->request->post())) {
|
||||||
|
$this->trigger(UserEvent::EVENT_BEFORE_PROFILE_UPDATE, $event);
|
||||||
|
if ($profile->save()) {
|
||||||
|
Yii::$app->getSession()->setFlash('success', Yii::t('usuario', 'Your profile has been updated'));
|
||||||
|
$this->trigger(UserEvent::EVENT_AFTER_PROFILE_UPDATE, $event);
|
||||||
|
|
||||||
|
return $this->refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Yii::debug(get_class(Yii::$app->session));
|
||||||
|
|
||||||
return $this->render(
|
return $this->render(
|
||||||
'show',
|
'profile',
|
||||||
[
|
[
|
||||||
'profile' => $profile,
|
'model' => $profile,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* @throws NotFoundHttpException
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function actionPrivacy()
|
||||||
|
{
|
||||||
|
if (!$this->module->enableGdprCompliance) {
|
||||||
|
throw new NotFoundHttpException();
|
||||||
|
}
|
||||||
|
return $this->render(
|
||||||
|
'privacy',
|
||||||
|
[
|
||||||
|
'module' => $this->module
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws NotFoundHttpException
|
||||||
|
* @throws \Throwable
|
||||||
|
* @throws \yii\base\Exception
|
||||||
|
* @throws \yii\base\InvalidConfigException
|
||||||
|
* @throws \yii\db\StaleObjectException
|
||||||
|
* @throws ForbiddenHttpException
|
||||||
|
* @return string|Response
|
||||||
|
*/
|
||||||
|
public function actionGdprDelete()
|
||||||
|
{
|
||||||
|
if (!$this->module->enableGdprCompliance) {
|
||||||
|
throw new NotFoundHttpException();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @var GdprDeleteForm $form
|
||||||
|
*/
|
||||||
|
$form = $this->make(GdprDeleteForm::class);
|
||||||
|
|
||||||
|
$user = $form->getUser();
|
||||||
|
/* @var $event GdprEvent */
|
||||||
|
$event = $this->make(GdprEvent::class, [$user]);
|
||||||
|
|
||||||
|
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
|
||||||
|
$this->trigger(GdprEvent::EVENT_BEFORE_DELETE, $event);
|
||||||
|
|
||||||
|
if ($event->isValid) {
|
||||||
|
Yii::$app->user->logout();
|
||||||
|
//Disconnect social networks
|
||||||
|
$networks = $this->socialNetworkAccountQuery->where(['user_id' => $user->id])->all();
|
||||||
|
foreach ($networks as $network) {
|
||||||
|
$this->disconnectSocialNetwork($network->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* @var $security SecurityHelper */
|
||||||
|
$security = $this->make(SecurityHelper::class);
|
||||||
|
$anonymReplacement = $this->module->gdprAnonymizePrefix . $user->id;
|
||||||
|
|
||||||
|
$user->updateAttributes(
|
||||||
|
[
|
||||||
|
'email' => $anonymReplacement . "@example.com",
|
||||||
|
'username' => $anonymReplacement,
|
||||||
|
'gdpr_deleted' => 1,
|
||||||
|
'blocked_at' => time(),
|
||||||
|
'auth_key' => $security->generateRandomString()
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$user->profile->updateAttributes(
|
||||||
|
[
|
||||||
|
'public_email' => $anonymReplacement . "@example.com",
|
||||||
|
'name' => $anonymReplacement,
|
||||||
|
'surname' => $anonymReplacement,
|
||||||
|
'gravatar_email' => $anonymReplacement . "@example.com",
|
||||||
|
'location' => $anonymReplacement,
|
||||||
|
'website' => $anonymReplacement . ".tld",
|
||||||
|
'bio' => Yii::t('usuario', 'Deleted by GDPR request')
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$this->trigger(GdprEvent::EVENT_AFTER_DELETE, $event);
|
||||||
|
|
||||||
|
Yii::$app->session->setFlash('info', Yii::t('usuario', 'Your personal information has been removed'));
|
||||||
|
|
||||||
|
return $this->goHome();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render(
|
||||||
|
'gdpr-delete',
|
||||||
|
[
|
||||||
|
'model' => $form,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actionGdprConsent()
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @var User $user
|
||||||
|
*/
|
||||||
|
$user = Yii::$app->user->identity;
|
||||||
|
if ($user->gdpr_consent) {
|
||||||
|
return $this->redirect(['profile']);
|
||||||
|
}
|
||||||
|
$model = new DynamicModel(['gdpr_consent']);
|
||||||
|
$model->addRule('gdpr_consent', 'boolean');
|
||||||
|
$model->addRule('gdpr_consent', 'default', ['value' => 0, 'skipOnEmpty' => false]);
|
||||||
|
$model->addRule(
|
||||||
|
'gdpr_consent',
|
||||||
|
'compare',
|
||||||
|
[
|
||||||
|
'compareValue' => true,
|
||||||
|
'message' => Yii::t('usuario', 'Your consent is required to work with this site'),
|
||||||
|
'when' => function () {
|
||||||
|
return $this->module->enableGdprCompliance;
|
||||||
|
},
|
||||||
|
]
|
||||||
|
);
|
||||||
|
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
|
||||||
|
$user->updateAttributes(
|
||||||
|
[
|
||||||
|
'gdpr_consent' => 1,
|
||||||
|
'gdpr_consent_date' => time(),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
return $this->redirect(['profile']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render(
|
||||||
|
'gdpr-consent',
|
||||||
|
[
|
||||||
|
'model' => $model,
|
||||||
|
'gdpr_consent_hint' => $this->module->getConsentMessage(),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exports the data from the current user in a mechanical readable format (csv). Properties exported can be defined
|
||||||
|
* in the module configuration.
|
||||||
|
*
|
||||||
|
* @throws NotFoundHttpException if gdpr compliance is not enabled
|
||||||
|
* @throws \Exception
|
||||||
|
* @throws \Throwable
|
||||||
|
*/
|
||||||
|
public function actionExport()
|
||||||
|
{
|
||||||
|
if (!$this->module->enableGdprCompliance) {
|
||||||
|
throw new NotFoundHttpException();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
$properties = $this->module->gdprExportProperties;
|
||||||
|
$user = Yii::$app->user->identity;
|
||||||
|
$data = [$properties, []];
|
||||||
|
|
||||||
|
$formatter = Yii::$app->formatter;
|
||||||
|
// override the default html-specific format for nulls
|
||||||
|
$formatter->nullDisplay = "";
|
||||||
|
|
||||||
|
foreach ($properties as $property) {
|
||||||
|
$data[1][] = $formatter->asText(ArrayHelper::getValue($user, $property));
|
||||||
|
}
|
||||||
|
|
||||||
|
array_walk($data[0], function (&$value, $key) {
|
||||||
|
$splitted = explode('.', $value);
|
||||||
|
$value = array_pop($splitted);
|
||||||
|
});
|
||||||
|
|
||||||
|
Yii::$app->response->headers->removeAll();
|
||||||
|
Yii::$app->response->headers->add('Content-type', 'text/csv');
|
||||||
|
Yii::$app->response->headers->add('Content-Disposition', 'attachment;filename=gdpr-data.csv');
|
||||||
|
Yii::$app->response->send();
|
||||||
|
$f = fopen('php://output', 'w');
|
||||||
|
foreach ($data as $line) {
|
||||||
|
fputcsv($f, $line);
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actionAccount()
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @var SettingsForm $form
|
||||||
|
*/
|
||||||
|
$form = $this->make(SettingsForm::class);
|
||||||
|
$event = $this->make(UserEvent::class, [$form->getUser()]);
|
||||||
|
|
||||||
|
$this->make(AjaxRequestModelValidator::class, [$form])->validate();
|
||||||
|
|
||||||
|
if ($form->load(Yii::$app->request->post())) {
|
||||||
|
$this->trigger(UserEvent::EVENT_BEFORE_ACCOUNT_UPDATE, $event);
|
||||||
|
|
||||||
|
if ($form->save()) {
|
||||||
|
Yii::$app->getSession()->setFlash(
|
||||||
|
'success',
|
||||||
|
Yii::t('usuario', 'Your account details have been updated')
|
||||||
|
);
|
||||||
|
$this->trigger(UserEvent::EVENT_AFTER_ACCOUNT_UPDATE, $event);
|
||||||
|
|
||||||
|
return $this->refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render(
|
||||||
|
'account',
|
||||||
|
[
|
||||||
|
'model' => $form,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actionConfirm($id, $code)
|
||||||
|
{
|
||||||
|
$user = $this->userQuery->whereId($id)->one();
|
||||||
|
|
||||||
|
if ($user === null || MailChangeStrategyInterface::TYPE_INSECURE === $this->module->emailChangeStrategy) {
|
||||||
|
throw new NotFoundHttpException();
|
||||||
|
}
|
||||||
|
$event = $this->make(UserEvent::class, [$user]);
|
||||||
|
|
||||||
|
$this->trigger(UserEvent::EVENT_BEFORE_CONFIRMATION, $event);
|
||||||
|
if ($this->make(EmailChangeService::class, [$code, $user])->run()) {
|
||||||
|
$this->trigger(UserEvent::EVENT_AFTER_CONFIRMATION, $event);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->redirect(['account']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actionNetworks()
|
||||||
|
{
|
||||||
|
return $this->render(
|
||||||
|
'networks',
|
||||||
|
[
|
||||||
|
'user' => Yii::$app->user->identity,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actionDisconnect($id)
|
||||||
|
{
|
||||||
|
$this->disconnectSocialNetwork($id);
|
||||||
|
return $this->redirect(['networks']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actionDelete()
|
||||||
|
{
|
||||||
|
if (!$this->module->allowAccountDelete) {
|
||||||
|
throw new NotFoundHttpException(Yii::t('usuario', 'Not found'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @var User $user
|
||||||
|
*/
|
||||||
|
$user = Yii::$app->user->identity;
|
||||||
|
$event = $this->make(UserEvent::class, [$user]);
|
||||||
|
Yii::$app->user->logout();
|
||||||
|
|
||||||
|
$this->trigger(UserEvent::EVENT_BEFORE_DELETE, $event);
|
||||||
|
$user->delete();
|
||||||
|
$this->trigger(UserEvent::EVENT_AFTER_DELETE, $event);
|
||||||
|
|
||||||
|
Yii::$app->session->setFlash('info', Yii::t('usuario', 'Your account has been completely deleted'));
|
||||||
|
|
||||||
|
return $this->goHome();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actionTwoFactor($id)
|
||||||
|
{
|
||||||
|
if (!$this->module->enableTwoFactorAuthentication) {
|
||||||
|
throw new ForbiddenHttpException(Yii::t('usuario', 'Application not configured for two factor authentication.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($id != Yii::$app->user->id) {
|
||||||
|
throw new ForbiddenHttpException();
|
||||||
|
}
|
||||||
|
|
||||||
|
$choice = Yii::$app->request->post('choice');
|
||||||
|
/** @var User $user */
|
||||||
|
$user = $this->userQuery->whereId($id)->one();
|
||||||
|
|
||||||
|
if (null === $user) {
|
||||||
|
throw new NotFoundHttpException();
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($choice) {
|
||||||
|
case 'google-authenticator':
|
||||||
|
$uri = $this->make(TwoFactorQrCodeUriGeneratorService::class, [$user])->run();
|
||||||
|
return $this->renderAjax('two-factor', ['id' => $id, 'uri' => $uri, 'user' => $user]);
|
||||||
|
case 'email':
|
||||||
|
$emailCode = $this->make(TwoFactorEmailCodeGeneratorService::class, [$user])->run();
|
||||||
|
return $this->renderAjax('two-factor-email', ['id' => $id, 'code' => $emailCode]);
|
||||||
|
case 'sms':
|
||||||
|
// get mobile phone, if exists
|
||||||
|
$mobilePhone = $user->getAuthTfMobilePhone();
|
||||||
|
$smsCode = $this->make(TwoFactorSmsCodeGeneratorService::class, [$user])->run();
|
||||||
|
return $this->renderAjax('two-factor-sms', ['id' => $id, 'code' => $smsCode, 'mobilePhone' => $mobilePhone]);
|
||||||
|
default:
|
||||||
|
throw new InvalidParamException("Invalid 2FA choice");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actionTwoFactorEnable($id)
|
||||||
|
{
|
||||||
|
if (!$this->module->enableTwoFactorAuthentication) {
|
||||||
|
throw new ForbiddenHttpException(Yii::t('usuario', 'Application not configured for two factor authentication.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
Yii::$app->response->format = Response::FORMAT_JSON;
|
||||||
|
|
||||||
|
/** @var User $user */
|
||||||
|
$user = $this->userQuery->whereId($id)->one();
|
||||||
|
|
||||||
|
if (null === $user) {
|
||||||
|
return [
|
||||||
|
'success' => false,
|
||||||
|
'message' => Yii::t('usuario', 'User not found.')
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$code = Yii::$app->request->get('code');
|
||||||
|
$module = Yii::$app->getModule('user');
|
||||||
|
$validators = $module->twoFactorAuthenticationValidators;
|
||||||
|
$choice = Yii::$app->request->get('choice');
|
||||||
|
$codeDurationTime = ArrayHelper::getValue($validators, $choice.'.codeDurationTime', 300);
|
||||||
|
$class = ArrayHelper::getValue($validators, $choice.'.class');
|
||||||
|
|
||||||
|
$object = $this
|
||||||
|
->make($class, [$user, $code, $this->module->twoFactorAuthenticationCycles]);
|
||||||
|
$success = $object->validate();
|
||||||
|
$success = $success && $user->updateAttributes(['auth_tf_enabled' => '1','auth_tf_type' => $choice]);
|
||||||
|
$message = $success ? $object->getSuccessMessage() : $object->getUnsuccessMessage($codeDurationTime);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'success' => $success,
|
||||||
|
'message' => $message
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actionTwoFactorDisable($id)
|
||||||
|
{
|
||||||
|
if (!$this->module->enableTwoFactorAuthentication) {
|
||||||
|
throw new ForbiddenHttpException(Yii::t('usuario', 'Application not configured for two factor authentication.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($id != Yii::$app->user->id) {
|
||||||
|
throw new ForbiddenHttpException();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var User $user
|
||||||
|
*/
|
||||||
|
$user = $this->userQuery->whereId($id)->one();
|
||||||
|
|
||||||
|
if (null === $user) {
|
||||||
|
throw new NotFoundHttpException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user->updateAttributes(['auth_tf_enabled' => '0', 'auth_tf_key' => null])) {
|
||||||
|
Yii::$app
|
||||||
|
->getSession()
|
||||||
|
->setFlash('success', Yii::t('usuario', 'Two factor authentication has been disabled.'));
|
||||||
|
} else {
|
||||||
|
Yii::$app
|
||||||
|
->getSession()
|
||||||
|
->setFlash('danger', Yii::t('usuario', 'Unable to disable Two factor authentication.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->redirect(['account']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display list session history.
|
||||||
|
*/
|
||||||
|
public function actionSessionHistory()
|
||||||
|
{
|
||||||
|
$searchModel = new SessionHistorySearch([
|
||||||
|
'user_id' => Yii::$app->user->id,
|
||||||
|
]);
|
||||||
|
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||||
|
|
||||||
|
return $this->render('session-history', [
|
||||||
|
'searchModel' => $searchModel,
|
||||||
|
'dataProvider' => $dataProvider,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Terminate all session user
|
||||||
|
*/
|
||||||
|
public function actionTerminateSessions()
|
||||||
|
{
|
||||||
|
$this->make(TerminateUserSessionsService::class, [Yii::$app->user->id])->run();
|
||||||
|
|
||||||
|
return $this->redirect(['session-history']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actionTwoFactorMobilePhone($id)
|
||||||
|
{
|
||||||
|
Yii::$app->response->format = Response::FORMAT_JSON;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @var User $user
|
||||||
|
*/
|
||||||
|
$user = $this->userQuery->whereId($id)->one();
|
||||||
|
|
||||||
|
if (null === $user) {
|
||||||
|
return [
|
||||||
|
'success' => false,
|
||||||
|
'message' => Yii::t('usuario', 'User not found.')
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$mobilePhone = Yii::$app->request->get('mobilephone');
|
||||||
|
$currentMobilePhone = $user->getAuthTfMobilePhone();
|
||||||
|
$success = false;
|
||||||
|
if ($currentMobilePhone == $mobilePhone) {
|
||||||
|
$success = true;
|
||||||
|
} else {
|
||||||
|
$success = $user->updateAttributes(['auth_tf_mobile_phone' => $mobilePhone]);
|
||||||
|
$success = $success && $this->make(TwoFactorSmsCodeGeneratorService::class, [$user])->run();
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'success' => $success,
|
||||||
|
'message' => $success
|
||||||
|
? Yii::t('usuario', 'Mobile phone number successfully enabled.')
|
||||||
|
: Yii::t('usuario', 'Error while enabling SMS two factor authentication. Please reload the page.'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @throws ForbiddenHttpException
|
||||||
|
* @throws NotFoundHttpException
|
||||||
|
* @throws \Exception
|
||||||
|
* @throws \Throwable
|
||||||
|
* @throws \yii\db\StaleObjectException
|
||||||
|
*/
|
||||||
|
protected function disconnectSocialNetwork($id)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @var SocialNetworkAccount $account
|
||||||
|
*/
|
||||||
|
$account = $this->socialNetworkAccountQuery->whereId($id)->one();
|
||||||
|
|
||||||
|
if ($account === null) {
|
||||||
|
throw new NotFoundHttpException();
|
||||||
|
}
|
||||||
|
if ($account->user_id !== Yii::$app->user->id) {
|
||||||
|
throw new ForbiddenHttpException();
|
||||||
|
}
|
||||||
|
$event = $this->make(SocialNetworkConnectEvent::class, [Yii::$app->user->identity, $account]);
|
||||||
|
|
||||||
|
$this->trigger(SocialNetworkConnectEvent::EVENT_BEFORE_DISCONNECT, $event);
|
||||||
|
$account->delete();
|
||||||
|
$this->trigger(SocialNetworkConnectEvent::EVENT_AFTER_DISCONNECT, $event);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -9,21 +9,21 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Controller;
|
namespace pcrt\User\Controller;
|
||||||
|
|
||||||
use Da\User\Event\FormEvent;
|
use pcrt\User\Event\FormEvent;
|
||||||
use Da\User\Event\ResetPasswordEvent;
|
use pcrt\User\Event\ResetPasswordEvent;
|
||||||
use Da\User\Factory\MailFactory;
|
use pcrt\User\Factory\MailFactory;
|
||||||
use Da\User\Form\RecoveryForm;
|
use pcrt\User\Form\RecoveryForm;
|
||||||
use Da\User\Model\Token;
|
use pcrt\User\Model\Token;
|
||||||
use Da\User\Module;
|
use pcrt\User\Module;
|
||||||
use Da\User\Query\TokenQuery;
|
use pcrt\User\Query\TokenQuery;
|
||||||
use Da\User\Query\UserQuery;
|
use pcrt\User\Query\UserQuery;
|
||||||
use Da\User\Service\PasswordRecoveryService;
|
use pcrt\User\Service\PasswordRecoveryService;
|
||||||
use Da\User\Service\ResetPasswordService;
|
use pcrt\User\Service\ResetPasswordService;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
use pcrt\User\Traits\ContainerAwareTrait;
|
||||||
use Da\User\Traits\ModuleAwareTrait;
|
use pcrt\User\Traits\ModuleAwareTrait;
|
||||||
use Da\User\Validator\AjaxRequestModelValidator;
|
use pcrt\User\Validator\AjaxRequestModelValidator;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\InvalidConfigException;
|
use yii\base\InvalidConfigException;
|
||||||
use yii\base\InvalidParamException;
|
use yii\base\InvalidParamException;
|
||||||
@ -89,14 +89,18 @@ class RecoveryController extends Controller
|
|||||||
throw new NotFoundHttpException();
|
throw new NotFoundHttpException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$request = Yii::$app->request;
|
||||||
|
|
||||||
/** @var RecoveryForm $form */
|
/** @var RecoveryForm $form */
|
||||||
$form = $this->make(RecoveryForm::class, [], ['scenario' => RecoveryForm::SCENARIO_REQUEST]);
|
$form = $this->make(RecoveryForm::class, [], ['scenario' => RecoveryForm::SCENARIO_REQUEST]);
|
||||||
|
if(!$request->getIsPost() && !empty($request->get('email'))) {
|
||||||
|
$form->email = $request->get('email');
|
||||||
|
}
|
||||||
$event = $this->make(FormEvent::class, [$form]);
|
$event = $this->make(FormEvent::class, [$form]);
|
||||||
|
|
||||||
$this->make(AjaxRequestModelValidator::class, [$form])->validate();
|
$this->make(AjaxRequestModelValidator::class, [$form])->validate();
|
||||||
|
|
||||||
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
|
if ($form->load($request->post()) && $form->validate()) {
|
||||||
$this->trigger(FormEvent::EVENT_BEFORE_REQUEST, $event);
|
$this->trigger(FormEvent::EVENT_BEFORE_REQUEST, $event);
|
||||||
|
|
||||||
$mailService = MailFactory::makeRecoveryMailerService($form->email);
|
$mailService = MailFactory::makeRecoveryMailerService($form->email);
|
||||||
@ -105,13 +109,16 @@ class RecoveryController extends Controller
|
|||||||
$this->trigger(FormEvent::EVENT_AFTER_REQUEST, $event);
|
$this->trigger(FormEvent::EVENT_AFTER_REQUEST, $event);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render(
|
Yii::$app->session->setFlash('info', Yii::t('usuario', 'Recovery message sent'));
|
||||||
'/shared/message',
|
return $this->redirect(['/user/login']);
|
||||||
[
|
|
||||||
'title' => Yii::t('usuario', 'Recovery message sent'),
|
// return $this->render(
|
||||||
'module' => $this->module,
|
// '/shared/message',
|
||||||
]
|
// [
|
||||||
);
|
// 'title' => Yii::t('usuario', 'Recovery message sent'),
|
||||||
|
// 'module' => $this->module,
|
||||||
|
// ]
|
||||||
|
// );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('request', ['model' => $form]);
|
return $this->render('request', ['model' => $form]);
|
||||||
@ -147,13 +154,14 @@ class RecoveryController extends Controller
|
|||||||
Yii::t('usuario', 'Recovery link is invalid or expired. Please try requesting a new one.')
|
Yii::t('usuario', 'Recovery link is invalid or expired. Please try requesting a new one.')
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->render(
|
// return $this->render(
|
||||||
'/shared/message',
|
// '/shared/message',
|
||||||
[
|
// [
|
||||||
'title' => Yii::t('usuario', 'Invalid or expired link'),
|
// 'title' => Yii::t('usuario', 'Invalid or expired link'),
|
||||||
'module' => $this->module,
|
// 'module' => $this->module,
|
||||||
]
|
// ]
|
||||||
);
|
// );
|
||||||
|
return $this->redirect(['/user/recovery/request']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var RecoveryForm $form */
|
/** @var RecoveryForm $form */
|
||||||
@ -168,13 +176,15 @@ class RecoveryController extends Controller
|
|||||||
|
|
||||||
Yii::$app->session->setFlash('success', Yii::t('usuario', 'Password has been changed'));
|
Yii::$app->session->setFlash('success', Yii::t('usuario', 'Password has been changed'));
|
||||||
|
|
||||||
return $this->render(
|
// return $this->render(
|
||||||
'/shared/message',
|
// '/shared/message',
|
||||||
[
|
// [
|
||||||
'title' => Yii::t('usuario', 'Password has been changed'),
|
// 'title' => Yii::t('usuario', 'Password has been changed'),
|
||||||
'module' => $this->module,
|
// 'module' => $this->module,
|
||||||
]
|
// ]
|
||||||
);
|
// );
|
||||||
|
|
||||||
|
return $this->redirect(['/user/login']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,27 +9,27 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Controller;
|
namespace pcrt\User\Controller;
|
||||||
|
|
||||||
use Da\User\Event\FormEvent;
|
use pcrt\User\Event\FormEvent;
|
||||||
use Da\User\Event\SocialNetworkConnectEvent;
|
use pcrt\User\Event\SocialNetworkConnectEvent;
|
||||||
use Da\User\Event\UserEvent;
|
use pcrt\User\Event\UserEvent;
|
||||||
use Da\User\Factory\MailFactory;
|
use pcrt\User\Factory\MailFactory;
|
||||||
use Da\User\Form\RegistrationForm;
|
use pcrt\User\Form\RegistrationForm;
|
||||||
use Da\User\Form\ResendForm;
|
use pcrt\User\Form\ResendForm;
|
||||||
use Da\User\Helper\SecurityHelper;
|
use pcrt\User\Helper\SecurityHelper;
|
||||||
use Da\User\Model\SocialNetworkAccount;
|
use pcrt\User\Model\SocialNetworkAccount;
|
||||||
use Da\User\Model\User;
|
use pcrt\User\Model\User;
|
||||||
use Da\User\Query\SocialNetworkAccountQuery;
|
use pcrt\User\Query\SocialNetworkAccountQuery;
|
||||||
use Da\User\Query\UserQuery;
|
use pcrt\User\Query\UserQuery;
|
||||||
use Da\User\Service\AccountConfirmationService;
|
use pcrt\User\Service\AccountConfirmationService;
|
||||||
use Da\User\Service\ResendConfirmationService;
|
use pcrt\User\Service\ResendConfirmationService;
|
||||||
use Da\User\Service\UserConfirmationService;
|
use pcrt\User\Service\UserConfirmationService;
|
||||||
use Da\User\Service\UserCreateService;
|
use pcrt\User\Service\UserCreateService;
|
||||||
use Da\User\Service\UserRegisterService;
|
use pcrt\User\Service\UserRegisterService;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
use pcrt\User\Traits\ContainerAwareTrait;
|
||||||
use Da\User\Traits\ModuleAwareTrait;
|
use pcrt\User\Traits\ModuleAwareTrait;
|
||||||
use Da\User\Validator\AjaxRequestModelValidator;
|
use pcrt\User\Validator\AjaxRequestModelValidator;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Module;
|
use yii\base\Module;
|
||||||
use yii\filters\AccessControl;
|
use yii\filters\AccessControl;
|
||||||
@ -135,13 +135,7 @@ class RegistrationController extends Controller
|
|||||||
Yii::$app->session->setFlash('info', Yii::t('usuario', 'Your account has been created'));
|
Yii::$app->session->setFlash('info', Yii::t('usuario', 'Your account has been created'));
|
||||||
}
|
}
|
||||||
$this->trigger(FormEvent::EVENT_AFTER_REGISTER, $event);
|
$this->trigger(FormEvent::EVENT_AFTER_REGISTER, $event);
|
||||||
return $this->render(
|
return $this->redirect(['/user/login']);
|
||||||
'/shared/message',
|
|
||||||
[
|
|
||||||
'title' => Yii::t('usuario', 'Your account has been created'),
|
|
||||||
'module' => $this->module,
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
Yii::$app->session->setFlash('danger', Yii::t('usuario', 'User could not be registered.'));
|
Yii::$app->session->setFlash('danger', Yii::t('usuario', 'User could not be registered.'));
|
||||||
} else {
|
} else {
|
||||||
@ -234,13 +228,14 @@ class RegistrationController extends Controller
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render(
|
// return $this->render(
|
||||||
'/shared/message',
|
// '/shared/message',
|
||||||
[
|
// [
|
||||||
'title' => Yii::t('usuario', 'Account confirmation'),
|
// 'title' => Yii::t('usuario', 'Account confirmation'),
|
||||||
'module' => $this->module,
|
// 'module' => $this->module,
|
||||||
]
|
// ]
|
||||||
);
|
// );
|
||||||
|
return $this->redirect(['/user/profile']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -285,15 +280,17 @@ class RegistrationController extends Controller
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render(
|
return $this->redirect(['/user/login']);
|
||||||
'/shared/message',
|
|
||||||
[
|
// return $this->render(
|
||||||
'title' => $success
|
// '/shared/message',
|
||||||
? Yii::t('usuario', 'A new confirmation link has been sent')
|
// [
|
||||||
: Yii::t('usuario', 'Unable to send confirmation link'),
|
// 'title' => $success
|
||||||
'module' => $this->module,
|
// ? Yii::t('usuario', 'A new confirmation link has been sent')
|
||||||
]
|
// : Yii::t('usuario', 'Unable to send confirmation link'),
|
||||||
);
|
// 'module' => $this->module,
|
||||||
|
// ]
|
||||||
|
// );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render(
|
return $this->render(
|
||||||
|
|||||||
@ -9,10 +9,10 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Controller;
|
namespace pcrt\User\Controller;
|
||||||
|
|
||||||
use Da\User\Model\Role;
|
use pcrt\User\Model\Role;
|
||||||
use Da\User\Search\RoleSearch;
|
use pcrt\User\Search\RoleSearch;
|
||||||
use yii\web\NotFoundHttpException;
|
use yii\web\NotFoundHttpException;
|
||||||
|
|
||||||
class RoleController extends AbstractAuthItemController
|
class RoleController extends AbstractAuthItemController
|
||||||
|
|||||||
@ -9,15 +9,15 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Controller;
|
namespace pcrt\User\Controller;
|
||||||
|
|
||||||
use Da\User\Filter\AccessRuleFilter;
|
use pcrt\User\Filter\AccessRuleFilter;
|
||||||
use Da\User\Model\Rule;
|
use pcrt\User\Model\Rule;
|
||||||
use Da\User\Search\RuleSearch;
|
use pcrt\User\Search\RuleSearch;
|
||||||
use Da\User\Service\AuthRuleEditionService;
|
use pcrt\User\Service\AuthRuleEditionService;
|
||||||
use Da\User\Traits\AuthManagerAwareTrait;
|
use pcrt\User\Traits\AuthManagerAwareTrait;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
use pcrt\User\Traits\ContainerAwareTrait;
|
||||||
use Da\User\Validator\AjaxRequestModelValidator;
|
use pcrt\User\Validator\AjaxRequestModelValidator;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\filters\AccessControl;
|
use yii\filters\AccessControl;
|
||||||
use yii\filters\VerbFilter;
|
use yii\filters\VerbFilter;
|
||||||
|
|||||||
@ -9,20 +9,20 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Controller;
|
namespace pcrt\User\Controller;
|
||||||
|
|
||||||
use Da\User\Contracts\AuthClientInterface;
|
use pcrt\User\Contracts\AuthClientInterface;
|
||||||
use Da\User\Event\FormEvent;
|
use pcrt\User\Event\FormEvent;
|
||||||
use Da\User\Event\UserEvent;
|
use pcrt\User\Event\UserEvent;
|
||||||
use Da\User\Form\LoginForm;
|
use pcrt\User\Form\LoginForm;
|
||||||
use Da\User\Model\User;
|
use pcrt\User\Model\User;
|
||||||
use Da\User\Query\SocialNetworkAccountQuery;
|
use pcrt\User\Query\SocialNetworkAccountQuery;
|
||||||
use Da\User\Service\SocialNetworkAccountConnectService;
|
use pcrt\User\Service\SocialNetworkAccountConnectService;
|
||||||
use Da\User\Service\SocialNetworkAuthenticateService;
|
use pcrt\User\Service\SocialNetworkAuthenticateService;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
use pcrt\User\Traits\ContainerAwareTrait;
|
||||||
use Da\User\Traits\ModuleAwareTrait;
|
use pcrt\User\Traits\ModuleAwareTrait;
|
||||||
use Da\User\Validator\TwoFactorEmailValidator;
|
use pcrt\User\Validator\TwoFactorEmailValidator;
|
||||||
use Da\User\Validator\TwoFactorTextMessageValidator;
|
use pcrt\User\Validator\TwoFactorTextMessageValidator;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\authclient\AuthAction;
|
use yii\authclient\AuthAction;
|
||||||
use yii\base\InvalidConfigException;
|
use yii\base\InvalidConfigException;
|
||||||
|
|||||||
@ -1,648 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the 2amigos/yii2-usuario project.
|
|
||||||
*
|
|
||||||
* (c) 2amigOS! <http://2amigos.us/>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view
|
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Da\User\Controller;
|
|
||||||
|
|
||||||
use Da\User\Contracts\MailChangeStrategyInterface;
|
|
||||||
use Da\User\Event\GdprEvent;
|
|
||||||
use Da\User\Event\ProfileEvent;
|
|
||||||
use Da\User\Event\SocialNetworkConnectEvent;
|
|
||||||
use Da\User\Event\UserEvent;
|
|
||||||
use Da\User\Form\GdprDeleteForm;
|
|
||||||
use Da\User\Form\SettingsForm;
|
|
||||||
use Da\User\Helper\SecurityHelper;
|
|
||||||
use Da\User\Model\Profile;
|
|
||||||
use Da\User\Model\SocialNetworkAccount;
|
|
||||||
use Da\User\Model\User;
|
|
||||||
use Da\User\Module;
|
|
||||||
use Da\User\Query\ProfileQuery;
|
|
||||||
use Da\User\Query\SocialNetworkAccountQuery;
|
|
||||||
use Da\User\Query\UserQuery;
|
|
||||||
use Da\User\Search\SessionHistorySearch;
|
|
||||||
use Da\User\Service\EmailChangeService;
|
|
||||||
use Da\User\Service\SessionHistory\TerminateUserSessionsService;
|
|
||||||
use Da\User\Service\TwoFactorEmailCodeGeneratorService;
|
|
||||||
use Da\User\Service\TwoFactorQrCodeUriGeneratorService;
|
|
||||||
use Da\User\Service\TwoFactorSmsCodeGeneratorService;
|
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
|
||||||
use Da\User\Traits\ModuleAwareTrait;
|
|
||||||
use Da\User\Validator\AjaxRequestModelValidator;
|
|
||||||
use Da\User\Validator\TwoFactorCodeValidator;
|
|
||||||
use Da\User\Validator\TwoFactorEmailValidator;
|
|
||||||
use Da\User\Validator\TwoFactorTextMessageValidator;
|
|
||||||
use Yii;
|
|
||||||
use yii\base\DynamicModel;
|
|
||||||
use yii\base\InvalidParamException;
|
|
||||||
use yii\filters\AccessControl;
|
|
||||||
use yii\filters\VerbFilter;
|
|
||||||
use yii\helpers\ArrayHelper;
|
|
||||||
use yii\web\Controller;
|
|
||||||
use yii\web\ForbiddenHttpException;
|
|
||||||
use yii\web\NotFoundHttpException;
|
|
||||||
use yii\web\Response;
|
|
||||||
|
|
||||||
class SettingsController extends Controller
|
|
||||||
{
|
|
||||||
use ContainerAwareTrait;
|
|
||||||
use ModuleAwareTrait;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public $defaultAction = 'profile';
|
|
||||||
|
|
||||||
protected $profileQuery;
|
|
||||||
protected $userQuery;
|
|
||||||
protected $socialNetworkAccountQuery;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SettingsController constructor.
|
|
||||||
*
|
|
||||||
* @param string $id
|
|
||||||
* @param Module $module
|
|
||||||
* @param ProfileQuery $profileQuery
|
|
||||||
* @param UserQuery $userQuery
|
|
||||||
* @param SocialNetworkAccountQuery $socialNetworkAccountQuery
|
|
||||||
* @param array $config
|
|
||||||
*/
|
|
||||||
public function __construct(
|
|
||||||
$id,
|
|
||||||
Module $module,
|
|
||||||
ProfileQuery $profileQuery,
|
|
||||||
UserQuery $userQuery,
|
|
||||||
SocialNetworkAccountQuery $socialNetworkAccountQuery,
|
|
||||||
array $config = []
|
|
||||||
) {
|
|
||||||
$this->profileQuery = $profileQuery;
|
|
||||||
$this->userQuery = $userQuery;
|
|
||||||
$this->socialNetworkAccountQuery = $socialNetworkAccountQuery;
|
|
||||||
parent::__construct($id, $module, $config);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function behaviors()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'verbs' => [
|
|
||||||
'class' => VerbFilter::class,
|
|
||||||
'actions' => [
|
|
||||||
'disconnect' => ['post'],
|
|
||||||
'delete' => ['post'],
|
|
||||||
'two-factor-disable' => ['post'],
|
|
||||||
'terminate-sessions' => ['post'],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'access' => [
|
|
||||||
'class' => AccessControl::class,
|
|
||||||
'rules' => [
|
|
||||||
[
|
|
||||||
'allow' => true,
|
|
||||||
'actions' => [
|
|
||||||
'profile',
|
|
||||||
'account',
|
|
||||||
'export',
|
|
||||||
'networks',
|
|
||||||
'privacy',
|
|
||||||
'gdpr-consent',
|
|
||||||
'gdpr-delete',
|
|
||||||
'disconnect',
|
|
||||||
'delete',
|
|
||||||
'two-factor',
|
|
||||||
'two-factor-enable',
|
|
||||||
'two-factor-disable',
|
|
||||||
'two-factor-mobile-phone'
|
|
||||||
],
|
|
||||||
'roles' => ['@'],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'allow' => true,
|
|
||||||
'actions' => ['confirm'],
|
|
||||||
'roles' => ['?', '@'],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'allow' => $this->getModule()->enableSessionHistory,
|
|
||||||
'actions' => ['session-history', 'terminate-sessions'],
|
|
||||||
'roles' => ['@'],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws \yii\base\InvalidConfigException
|
|
||||||
* @return string|Response
|
|
||||||
*/
|
|
||||||
public function actionProfile()
|
|
||||||
{
|
|
||||||
$profile = $this->profileQuery->whereUserId(Yii::$app->user->identity->getId())->one();
|
|
||||||
|
|
||||||
if ($profile === null) {
|
|
||||||
$profile = $this->make(Profile::class);
|
|
||||||
$profile->link('user', Yii::$app->user->identity);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @var ProfileEvent $event
|
|
||||||
*/
|
|
||||||
$event = $this->make(ProfileEvent::class, [$profile]);
|
|
||||||
|
|
||||||
$this->make(AjaxRequestModelValidator::class, [$profile])->validate();
|
|
||||||
|
|
||||||
if ($profile->load(Yii::$app->request->post())) {
|
|
||||||
$this->trigger(UserEvent::EVENT_BEFORE_PROFILE_UPDATE, $event);
|
|
||||||
if ($profile->save()) {
|
|
||||||
Yii::$app->getSession()->setFlash('success', Yii::t('usuario', 'Your profile has been updated'));
|
|
||||||
$this->trigger(UserEvent::EVENT_AFTER_PROFILE_UPDATE, $event);
|
|
||||||
|
|
||||||
return $this->refresh();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render(
|
|
||||||
'profile',
|
|
||||||
[
|
|
||||||
'model' => $profile,
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws NotFoundHttpException
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function actionPrivacy()
|
|
||||||
{
|
|
||||||
if (!$this->module->enableGdprCompliance) {
|
|
||||||
throw new NotFoundHttpException();
|
|
||||||
}
|
|
||||||
return $this->render(
|
|
||||||
'privacy',
|
|
||||||
[
|
|
||||||
'module' => $this->module
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws NotFoundHttpException
|
|
||||||
* @throws \Throwable
|
|
||||||
* @throws \yii\base\Exception
|
|
||||||
* @throws \yii\base\InvalidConfigException
|
|
||||||
* @throws \yii\db\StaleObjectException
|
|
||||||
* @throws ForbiddenHttpException
|
|
||||||
* @return string|Response
|
|
||||||
*/
|
|
||||||
public function actionGdprDelete()
|
|
||||||
{
|
|
||||||
if (!$this->module->enableGdprCompliance) {
|
|
||||||
throw new NotFoundHttpException();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @var GdprDeleteForm $form
|
|
||||||
*/
|
|
||||||
$form = $this->make(GdprDeleteForm::class);
|
|
||||||
|
|
||||||
$user = $form->getUser();
|
|
||||||
/* @var $event GdprEvent */
|
|
||||||
$event = $this->make(GdprEvent::class, [$user]);
|
|
||||||
|
|
||||||
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
|
|
||||||
$this->trigger(GdprEvent::EVENT_BEFORE_DELETE, $event);
|
|
||||||
|
|
||||||
if ($event->isValid) {
|
|
||||||
Yii::$app->user->logout();
|
|
||||||
//Disconnect social networks
|
|
||||||
$networks = $this->socialNetworkAccountQuery->where(['user_id' => $user->id])->all();
|
|
||||||
foreach ($networks as $network) {
|
|
||||||
$this->disconnectSocialNetwork($network->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* @var $security SecurityHelper */
|
|
||||||
$security = $this->make(SecurityHelper::class);
|
|
||||||
$anonymReplacement = $this->module->gdprAnonymizePrefix . $user->id;
|
|
||||||
|
|
||||||
$user->updateAttributes(
|
|
||||||
[
|
|
||||||
'email' => $anonymReplacement . "@example.com",
|
|
||||||
'username' => $anonymReplacement,
|
|
||||||
'gdpr_deleted' => 1,
|
|
||||||
'blocked_at' => time(),
|
|
||||||
'auth_key' => $security->generateRandomString()
|
|
||||||
]
|
|
||||||
);
|
|
||||||
$user->profile->updateAttributes(
|
|
||||||
[
|
|
||||||
'public_email' => $anonymReplacement . "@example.com",
|
|
||||||
'name' => $anonymReplacement,
|
|
||||||
'gravatar_email' => $anonymReplacement . "@example.com",
|
|
||||||
'location' => $anonymReplacement,
|
|
||||||
'website' => $anonymReplacement . ".tld",
|
|
||||||
'bio' => Yii::t('usuario', 'Deleted by GDPR request')
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$this->trigger(GdprEvent::EVENT_AFTER_DELETE, $event);
|
|
||||||
|
|
||||||
Yii::$app->session->setFlash('info', Yii::t('usuario', 'Your personal information has been removed'));
|
|
||||||
|
|
||||||
return $this->goHome();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render(
|
|
||||||
'gdpr-delete',
|
|
||||||
[
|
|
||||||
'model' => $form,
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function actionGdprConsent()
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @var User $user
|
|
||||||
*/
|
|
||||||
$user = Yii::$app->user->identity;
|
|
||||||
if ($user->gdpr_consent) {
|
|
||||||
return $this->redirect(['profile']);
|
|
||||||
}
|
|
||||||
$model = new DynamicModel(['gdpr_consent']);
|
|
||||||
$model->addRule('gdpr_consent', 'boolean');
|
|
||||||
$model->addRule('gdpr_consent', 'default', ['value' => 0, 'skipOnEmpty' => false]);
|
|
||||||
$model->addRule(
|
|
||||||
'gdpr_consent',
|
|
||||||
'compare',
|
|
||||||
[
|
|
||||||
'compareValue' => true,
|
|
||||||
'message' => Yii::t('usuario', 'Your consent is required to work with this site'),
|
|
||||||
'when' => function () {
|
|
||||||
return $this->module->enableGdprCompliance;
|
|
||||||
},
|
|
||||||
]
|
|
||||||
);
|
|
||||||
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
|
|
||||||
$user->updateAttributes(
|
|
||||||
[
|
|
||||||
'gdpr_consent' => 1,
|
|
||||||
'gdpr_consent_date' => time(),
|
|
||||||
]
|
|
||||||
);
|
|
||||||
return $this->redirect(['profile']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render(
|
|
||||||
'gdpr-consent',
|
|
||||||
[
|
|
||||||
'model' => $model,
|
|
||||||
'gdpr_consent_hint' => $this->module->getConsentMessage(),
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Exports the data from the current user in a mechanical readable format (csv). Properties exported can be defined
|
|
||||||
* in the module configuration.
|
|
||||||
*
|
|
||||||
* @throws NotFoundHttpException if gdpr compliance is not enabled
|
|
||||||
* @throws \Exception
|
|
||||||
* @throws \Throwable
|
|
||||||
*/
|
|
||||||
public function actionExport()
|
|
||||||
{
|
|
||||||
if (!$this->module->enableGdprCompliance) {
|
|
||||||
throw new NotFoundHttpException();
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
$properties = $this->module->gdprExportProperties;
|
|
||||||
$user = Yii::$app->user->identity;
|
|
||||||
$data = [$properties, []];
|
|
||||||
|
|
||||||
$formatter = Yii::$app->formatter;
|
|
||||||
// override the default html-specific format for nulls
|
|
||||||
$formatter->nullDisplay = "";
|
|
||||||
|
|
||||||
foreach ($properties as $property) {
|
|
||||||
$data[1][] = $formatter->asText(ArrayHelper::getValue($user, $property));
|
|
||||||
}
|
|
||||||
|
|
||||||
array_walk($data[0], function (&$value, $key) {
|
|
||||||
$splitted = explode('.', $value);
|
|
||||||
$value = array_pop($splitted);
|
|
||||||
});
|
|
||||||
|
|
||||||
Yii::$app->response->headers->removeAll();
|
|
||||||
Yii::$app->response->headers->add('Content-type', 'text/csv');
|
|
||||||
Yii::$app->response->headers->add('Content-Disposition', 'attachment;filename=gdpr-data.csv');
|
|
||||||
Yii::$app->response->send();
|
|
||||||
$f = fopen('php://output', 'w');
|
|
||||||
foreach ($data as $line) {
|
|
||||||
fputcsv($f, $line);
|
|
||||||
}
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
throw $e;
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
throw $e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function actionAccount()
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @var SettingsForm $form
|
|
||||||
*/
|
|
||||||
$form = $this->make(SettingsForm::class);
|
|
||||||
$event = $this->make(UserEvent::class, [$form->getUser()]);
|
|
||||||
|
|
||||||
$this->make(AjaxRequestModelValidator::class, [$form])->validate();
|
|
||||||
|
|
||||||
if ($form->load(Yii::$app->request->post())) {
|
|
||||||
$this->trigger(UserEvent::EVENT_BEFORE_ACCOUNT_UPDATE, $event);
|
|
||||||
|
|
||||||
if ($form->save()) {
|
|
||||||
Yii::$app->getSession()->setFlash(
|
|
||||||
'success',
|
|
||||||
Yii::t('usuario', 'Your account details have been updated')
|
|
||||||
);
|
|
||||||
$this->trigger(UserEvent::EVENT_AFTER_ACCOUNT_UPDATE, $event);
|
|
||||||
|
|
||||||
return $this->refresh();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render(
|
|
||||||
'account',
|
|
||||||
[
|
|
||||||
'model' => $form,
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function actionConfirm($id, $code)
|
|
||||||
{
|
|
||||||
$user = $this->userQuery->whereId($id)->one();
|
|
||||||
|
|
||||||
if ($user === null || MailChangeStrategyInterface::TYPE_INSECURE === $this->module->emailChangeStrategy) {
|
|
||||||
throw new NotFoundHttpException();
|
|
||||||
}
|
|
||||||
$event = $this->make(UserEvent::class, [$user]);
|
|
||||||
|
|
||||||
$this->trigger(UserEvent::EVENT_BEFORE_CONFIRMATION, $event);
|
|
||||||
if ($this->make(EmailChangeService::class, [$code, $user])->run()) {
|
|
||||||
$this->trigger(UserEvent::EVENT_AFTER_CONFIRMATION, $event);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->redirect(['account']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function actionNetworks()
|
|
||||||
{
|
|
||||||
return $this->render(
|
|
||||||
'networks',
|
|
||||||
[
|
|
||||||
'user' => Yii::$app->user->identity,
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function actionDisconnect($id)
|
|
||||||
{
|
|
||||||
$this->disconnectSocialNetwork($id);
|
|
||||||
return $this->redirect(['networks']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function actionDelete()
|
|
||||||
{
|
|
||||||
if (!$this->module->allowAccountDelete) {
|
|
||||||
throw new NotFoundHttpException(Yii::t('usuario', 'Not found'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @var User $user
|
|
||||||
*/
|
|
||||||
$user = Yii::$app->user->identity;
|
|
||||||
$event = $this->make(UserEvent::class, [$user]);
|
|
||||||
Yii::$app->user->logout();
|
|
||||||
|
|
||||||
$this->trigger(UserEvent::EVENT_BEFORE_DELETE, $event);
|
|
||||||
$user->delete();
|
|
||||||
$this->trigger(UserEvent::EVENT_AFTER_DELETE, $event);
|
|
||||||
|
|
||||||
Yii::$app->session->setFlash('info', Yii::t('usuario', 'Your account has been completely deleted'));
|
|
||||||
|
|
||||||
return $this->goHome();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function actionTwoFactor($id)
|
|
||||||
{
|
|
||||||
if (!$this->module->enableTwoFactorAuthentication) {
|
|
||||||
throw new ForbiddenHttpException(Yii::t('usuario', 'Application not configured for two factor authentication.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($id != Yii::$app->user->id) {
|
|
||||||
throw new ForbiddenHttpException();
|
|
||||||
}
|
|
||||||
|
|
||||||
$choice = Yii::$app->request->post('choice');
|
|
||||||
/** @var User $user */
|
|
||||||
$user = $this->userQuery->whereId($id)->one();
|
|
||||||
|
|
||||||
if (null === $user) {
|
|
||||||
throw new NotFoundHttpException();
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ($choice) {
|
|
||||||
case 'google-authenticator':
|
|
||||||
$uri = $this->make(TwoFactorQrCodeUriGeneratorService::class, [$user])->run();
|
|
||||||
return $this->renderAjax('two-factor', ['id' => $id, 'uri' => $uri, 'user' => $user]);
|
|
||||||
case 'email':
|
|
||||||
$emailCode = $this->make(TwoFactorEmailCodeGeneratorService::class, [$user])->run();
|
|
||||||
return $this->renderAjax('two-factor-email', ['id' => $id, 'code' => $emailCode]);
|
|
||||||
case 'sms':
|
|
||||||
// get mobile phone, if exists
|
|
||||||
$mobilePhone = $user->getAuthTfMobilePhone();
|
|
||||||
$smsCode = $this->make(TwoFactorSmsCodeGeneratorService::class, [$user])->run();
|
|
||||||
return $this->renderAjax('two-factor-sms', ['id' => $id, 'code' => $smsCode, 'mobilePhone' => $mobilePhone]);
|
|
||||||
default:
|
|
||||||
throw new InvalidParamException("Invalid 2FA choice");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function actionTwoFactorEnable($id)
|
|
||||||
{
|
|
||||||
if (!$this->module->enableTwoFactorAuthentication) {
|
|
||||||
throw new ForbiddenHttpException(Yii::t('usuario', 'Application not configured for two factor authentication.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
Yii::$app->response->format = Response::FORMAT_JSON;
|
|
||||||
|
|
||||||
/** @var User $user */
|
|
||||||
$user = $this->userQuery->whereId($id)->one();
|
|
||||||
|
|
||||||
if (null === $user) {
|
|
||||||
return [
|
|
||||||
'success' => false,
|
|
||||||
'message' => Yii::t('usuario', 'User not found.')
|
|
||||||
];
|
|
||||||
}
|
|
||||||
$code = Yii::$app->request->get('code');
|
|
||||||
$module = Yii::$app->getModule('user');
|
|
||||||
$validators = $module->twoFactorAuthenticationValidators;
|
|
||||||
$choice = Yii::$app->request->get('choice');
|
|
||||||
$codeDurationTime = ArrayHelper::getValue($validators, $choice.'.codeDurationTime', 300);
|
|
||||||
$class = ArrayHelper::getValue($validators, $choice.'.class');
|
|
||||||
|
|
||||||
$object = $this
|
|
||||||
->make($class, [$user, $code, $this->module->twoFactorAuthenticationCycles]);
|
|
||||||
$success = $object->validate();
|
|
||||||
$success = $success && $user->updateAttributes(['auth_tf_enabled' => '1','auth_tf_type' => $choice]);
|
|
||||||
$message = $success ? $object->getSuccessMessage() : $object->getUnsuccessMessage($codeDurationTime);
|
|
||||||
|
|
||||||
return [
|
|
||||||
'success' => $success,
|
|
||||||
'message' => $message
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function actionTwoFactorDisable($id)
|
|
||||||
{
|
|
||||||
if (!$this->module->enableTwoFactorAuthentication) {
|
|
||||||
throw new ForbiddenHttpException(Yii::t('usuario', 'Application not configured for two factor authentication.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($id != Yii::$app->user->id) {
|
|
||||||
throw new ForbiddenHttpException();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var User $user
|
|
||||||
*/
|
|
||||||
$user = $this->userQuery->whereId($id)->one();
|
|
||||||
|
|
||||||
if (null === $user) {
|
|
||||||
throw new NotFoundHttpException();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($user->updateAttributes(['auth_tf_enabled' => '0', 'auth_tf_key' => null])) {
|
|
||||||
Yii::$app
|
|
||||||
->getSession()
|
|
||||||
->setFlash('success', Yii::t('usuario', 'Two factor authentication has been disabled.'));
|
|
||||||
} else {
|
|
||||||
Yii::$app
|
|
||||||
->getSession()
|
|
||||||
->setFlash('danger', Yii::t('usuario', 'Unable to disable Two factor authentication.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->redirect(['account']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Display list session history.
|
|
||||||
*/
|
|
||||||
public function actionSessionHistory()
|
|
||||||
{
|
|
||||||
$searchModel = new SessionHistorySearch([
|
|
||||||
'user_id' => Yii::$app->user->id,
|
|
||||||
]);
|
|
||||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
|
||||||
|
|
||||||
return $this->render('session-history', [
|
|
||||||
'searchModel' => $searchModel,
|
|
||||||
'dataProvider' => $dataProvider,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Terminate all session user
|
|
||||||
*/
|
|
||||||
public function actionTerminateSessions()
|
|
||||||
{
|
|
||||||
$this->make(TerminateUserSessionsService::class, [Yii::$app->user->id])->run();
|
|
||||||
|
|
||||||
return $this->redirect(['session-history']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function actionTwoFactorMobilePhone($id)
|
|
||||||
{
|
|
||||||
Yii::$app->response->format = Response::FORMAT_JSON;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @var User $user
|
|
||||||
*/
|
|
||||||
$user = $this->userQuery->whereId($id)->one();
|
|
||||||
|
|
||||||
if (null === $user) {
|
|
||||||
return [
|
|
||||||
'success' => false,
|
|
||||||
'message' => Yii::t('usuario', 'User not found.')
|
|
||||||
];
|
|
||||||
}
|
|
||||||
$mobilePhone = Yii::$app->request->get('mobilephone');
|
|
||||||
$currentMobilePhone = $user->getAuthTfMobilePhone();
|
|
||||||
$success = false;
|
|
||||||
if ($currentMobilePhone == $mobilePhone) {
|
|
||||||
$success = true;
|
|
||||||
} else {
|
|
||||||
$success = $user->updateAttributes(['auth_tf_mobile_phone' => $mobilePhone]);
|
|
||||||
$success = $success && $this->make(TwoFactorSmsCodeGeneratorService::class, [$user])->run();
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
'success' => $success,
|
|
||||||
'message' => $success
|
|
||||||
? Yii::t('usuario', 'Mobile phone number successfully enabled.')
|
|
||||||
: Yii::t('usuario', 'Error while enabling SMS two factor authentication. Please reload the page.'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $id
|
|
||||||
* @throws ForbiddenHttpException
|
|
||||||
* @throws NotFoundHttpException
|
|
||||||
* @throws \Exception
|
|
||||||
* @throws \Throwable
|
|
||||||
* @throws \yii\db\StaleObjectException
|
|
||||||
*/
|
|
||||||
protected function disconnectSocialNetwork($id)
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @var SocialNetworkAccount $account
|
|
||||||
*/
|
|
||||||
$account = $this->socialNetworkAccountQuery->whereId($id)->one();
|
|
||||||
|
|
||||||
if ($account === null) {
|
|
||||||
throw new NotFoundHttpException();
|
|
||||||
}
|
|
||||||
if ($account->user_id !== Yii::$app->user->id) {
|
|
||||||
throw new ForbiddenHttpException();
|
|
||||||
}
|
|
||||||
$event = $this->make(SocialNetworkConnectEvent::class, [Yii::$app->user->identity, $account]);
|
|
||||||
|
|
||||||
$this->trigger(SocialNetworkConnectEvent::EVENT_BEFORE_DISCONNECT, $event);
|
|
||||||
$account->delete();
|
|
||||||
$this->trigger(SocialNetworkConnectEvent::EVENT_AFTER_DISCONNECT, $event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -9,20 +9,20 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Controller\api\v1;
|
namespace pcrt\User\Controller\api\v1;
|
||||||
|
|
||||||
use Da\User\Event\UserEvent;
|
use pcrt\User\Event\UserEvent;
|
||||||
use Da\User\Factory\MailFactory;
|
use pcrt\User\Factory\MailFactory;
|
||||||
use Da\User\Model\Assignment;
|
use pcrt\User\Model\Assignment;
|
||||||
use Da\User\Model\Profile;
|
use pcrt\User\Model\Profile;
|
||||||
use Da\User\Model\User;
|
use pcrt\User\Model\User;
|
||||||
use Da\User\Query\UserQuery;
|
use pcrt\User\Query\UserQuery;
|
||||||
use Da\User\Service\PasswordExpireService;
|
use pcrt\User\Service\PasswordExpireService;
|
||||||
use Da\User\Service\PasswordRecoveryService;
|
use pcrt\User\Service\PasswordRecoveryService;
|
||||||
use Da\User\Service\UserBlockService;
|
use pcrt\User\Service\UserBlockService;
|
||||||
use Da\User\Service\UserConfirmationService;
|
use pcrt\User\Service\UserConfirmationService;
|
||||||
use Da\User\Service\UserCreateService;
|
use pcrt\User\Service\UserCreateService;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
use pcrt\User\Traits\ContainerAwareTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Module;
|
use yii\base\Module;
|
||||||
use yii\db\ActiveRecord;
|
use yii\db\ActiveRecord;
|
||||||
@ -35,7 +35,7 @@ use yii\web\ServerErrorHttpException;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller that provides REST APIs to manage users.
|
* Controller that provides REST APIs to manage users.
|
||||||
* This controller is equivalent to `Da\User\Controller\AdminController`.
|
* This controller is equivalent to `pcrt\User\Controller\AdminController`.
|
||||||
*
|
*
|
||||||
* TODO:
|
* TODO:
|
||||||
* - `Info` and `SwitchIdentity` actions were not developed yet.
|
* - `Info` and `SwitchIdentity` actions were not developed yet.
|
||||||
@ -48,7 +48,7 @@ class AdminController extends ActiveController
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public $modelClass = 'Da\User\Model\User';
|
public $modelClass = 'pcrt\User\Model\User';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Event;
|
namespace pcrt\User\Event;
|
||||||
|
|
||||||
use yii\base\Event;
|
use yii\base\Event;
|
||||||
use yii\base\Model;
|
use yii\base\Model;
|
||||||
|
|||||||
@ -9,9 +9,9 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Event;
|
namespace pcrt\User\Event;
|
||||||
|
|
||||||
use Da\User\Model\User;
|
use pcrt\User\Model\User;
|
||||||
use yii\base\Event;
|
use yii\base\Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -9,10 +9,10 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Event;
|
namespace pcrt\User\Event;
|
||||||
|
|
||||||
use Da\User\Model\User;
|
use pcrt\User\Model\User;
|
||||||
use Da\User\Service\MailService;
|
use pcrt\User\Service\MailService;
|
||||||
use yii\base\Event;
|
use yii\base\Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -9,9 +9,9 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Event;
|
namespace pcrt\User\Event;
|
||||||
|
|
||||||
use Da\User\Model\Profile;
|
use pcrt\User\Model\Profile;
|
||||||
use yii\base\Event;
|
use yii\base\Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -9,10 +9,10 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Event;
|
namespace pcrt\User\Event;
|
||||||
|
|
||||||
use Da\User\Form\RecoveryForm;
|
use pcrt\User\Form\RecoveryForm;
|
||||||
use Da\User\Model\Token;
|
use pcrt\User\Model\Token;
|
||||||
use yii\base\Event;
|
use yii\base\Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,7 +29,7 @@ final class ResetPasswordEvent extends Event
|
|||||||
protected $form;
|
protected $form;
|
||||||
protected $token;
|
protected $token;
|
||||||
|
|
||||||
public function __construct(Token $token = null, RecoveryForm $form = null, array $config = [])
|
public function __construct(?Token $token = null, ?RecoveryForm $form = null, array $config = [])
|
||||||
{
|
{
|
||||||
$this->form = $form;
|
$this->form = $form;
|
||||||
$this->token = $token;
|
$this->token = $token;
|
||||||
|
|||||||
@ -9,9 +9,9 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Event;
|
namespace pcrt\User\Event;
|
||||||
|
|
||||||
use Da\User\Model\User;
|
use pcrt\User\Model\User;
|
||||||
use yii\base\Event;
|
use yii\base\Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -9,9 +9,9 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Event;
|
namespace pcrt\User\Event;
|
||||||
|
|
||||||
use Da\User\Model\SocialNetworkAccount;
|
use pcrt\User\Model\SocialNetworkAccount;
|
||||||
use yii\authclient\ClientInterface;
|
use yii\authclient\ClientInterface;
|
||||||
use yii\base\Event;
|
use yii\base\Event;
|
||||||
|
|
||||||
|
|||||||
@ -9,10 +9,10 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Event;
|
namespace pcrt\User\Event;
|
||||||
|
|
||||||
use Da\User\Model\SocialNetworkAccount;
|
use pcrt\User\Model\SocialNetworkAccount;
|
||||||
use Da\User\Model\User;
|
use pcrt\User\Model\User;
|
||||||
use yii\base\Event;
|
use yii\base\Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -9,9 +9,9 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Event;
|
namespace pcrt\User\Event;
|
||||||
|
|
||||||
use Da\User\Model\User;
|
use pcrt\User\Model\User;
|
||||||
use yii\base\Event;
|
use yii\base\Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Factory;
|
namespace pcrt\User\Factory;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Yii;
|
use Yii;
|
||||||
|
|||||||
@ -9,13 +9,13 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Factory;
|
namespace pcrt\User\Factory;
|
||||||
|
|
||||||
use Da\User\Contracts\MailChangeStrategyInterface;
|
use pcrt\User\Contracts\MailChangeStrategyInterface;
|
||||||
use Da\User\Form\SettingsForm;
|
use pcrt\User\Form\SettingsForm;
|
||||||
use Da\User\Strategy\DefaultEmailChangeStrategy;
|
use pcrt\User\Strategy\DefaultEmailChangeStrategy;
|
||||||
use Da\User\Strategy\InsecureEmailChangeStrategy;
|
use pcrt\User\Strategy\InsecureEmailChangeStrategy;
|
||||||
use Da\User\Strategy\SecureEmailChangeStrategy;
|
use pcrt\User\Strategy\SecureEmailChangeStrategy;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\InvalidParamException;
|
use yii\base\InvalidParamException;
|
||||||
|
|||||||
@ -9,13 +9,13 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Factory;
|
namespace pcrt\User\Factory;
|
||||||
|
|
||||||
use Da\User\Event\MailEvent;
|
use pcrt\User\Event\MailEvent;
|
||||||
use Da\User\Model\Token;
|
use pcrt\User\Model\Token;
|
||||||
use Da\User\Model\User;
|
use pcrt\User\Model\User;
|
||||||
use Da\User\Module;
|
use pcrt\User\Module;
|
||||||
use Da\User\Service\MailService;
|
use pcrt\User\Service\MailService;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\InvalidConfigException;
|
use yii\base\InvalidConfigException;
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ class MailFactory
|
|||||||
* @throws InvalidConfigException
|
* @throws InvalidConfigException
|
||||||
* @return MailService
|
* @return MailService
|
||||||
*/
|
*/
|
||||||
public static function makeRecoveryMailerService($email, Token $token = null)
|
public static function makeRecoveryMailerService($email, ?Token $token = null)
|
||||||
{
|
{
|
||||||
/** @var Module $module */
|
/** @var Module $module */
|
||||||
$module = Yii::$app->getModule('user');
|
$module = Yii::$app->getModule('user');
|
||||||
@ -74,7 +74,7 @@ class MailFactory
|
|||||||
* @throws InvalidConfigException
|
* @throws InvalidConfigException
|
||||||
* @return MailService
|
* @return MailService
|
||||||
*/
|
*/
|
||||||
public static function makeConfirmationMailerService(User $user, Token $token = null)
|
public static function makeConfirmationMailerService(User $user, ?Token $token = null)
|
||||||
{
|
{
|
||||||
/** @var Module $module */
|
/** @var Module $module */
|
||||||
$module = Yii::$app->getModule('user');
|
$module = Yii::$app->getModule('user');
|
||||||
|
|||||||
@ -9,9 +9,9 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Factory;
|
namespace pcrt\User\Factory;
|
||||||
|
|
||||||
use Da\User\Model\Token;
|
use pcrt\User\Model\Token;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\InvalidConfigException;
|
use yii\base\InvalidConfigException;
|
||||||
|
|
||||||
|
|||||||
@ -9,11 +9,11 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Filter;
|
namespace pcrt\User\Filter;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use Da\User\Model\User;
|
use pcrt\User\Model\User;
|
||||||
use Da\User\Traits\ModuleAwareTrait;
|
use pcrt\User\Traits\ModuleAwareTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\filters\AccessRule;
|
use yii\filters\AccessRule;
|
||||||
|
|
||||||
|
|||||||
@ -9,10 +9,10 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Filter;
|
namespace pcrt\User\Filter;
|
||||||
|
|
||||||
use Da\User\Model\User;
|
use pcrt\User\Model\User;
|
||||||
use Da\User\Module;
|
use pcrt\User\Module;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\ActionFilter;
|
use yii\base\ActionFilter;
|
||||||
|
|
||||||
|
|||||||
@ -9,11 +9,11 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Filter;
|
namespace pcrt\User\Filter;
|
||||||
|
|
||||||
use Da\User\Model\User;
|
use pcrt\User\Model\User;
|
||||||
use Da\User\Module;
|
use pcrt\User\Module;
|
||||||
use Da\User\Traits\AuthManagerAwareTrait;
|
use pcrt\User\Traits\AuthManagerAwareTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\ActionFilter;
|
use yii\base\ActionFilter;
|
||||||
|
|
||||||
|
|||||||
@ -9,17 +9,17 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Form;
|
namespace pcrt\User\Form;
|
||||||
|
|
||||||
use Da\User\Helper\SecurityHelper;
|
use pcrt\User\Helper\SecurityHelper;
|
||||||
use Da\User\Model\User;
|
use pcrt\User\Model\User;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
use pcrt\User\Traits\ContainerAwareTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Model;
|
use yii\base\Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class GdprDeleteForm
|
* Class GdprDeleteForm
|
||||||
* @package Da\User\Form
|
* @package pcrt\User\Form
|
||||||
*/
|
*/
|
||||||
class GdprDeleteForm extends Model
|
class GdprDeleteForm extends Model
|
||||||
{
|
{
|
||||||
|
|||||||
@ -9,16 +9,16 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Form;
|
namespace pcrt\User\Form;
|
||||||
|
|
||||||
use Da\User\Helper\SecurityHelper;
|
use pcrt\User\Helper\SecurityHelper;
|
||||||
use Da\User\Model\User;
|
use pcrt\User\Model\User;
|
||||||
use Da\User\Query\UserQuery;
|
use pcrt\User\Query\UserQuery;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
use pcrt\User\Traits\ContainerAwareTrait;
|
||||||
use Da\User\Traits\ModuleAwareTrait;
|
use pcrt\User\Traits\ModuleAwareTrait;
|
||||||
use Da\User\Validator\TwoFactorCodeValidator;
|
use pcrt\User\Validator\TwoFactorCodeValidator;
|
||||||
use Da\User\Validator\TwoFactorEmailValidator;
|
use pcrt\User\Validator\TwoFactorEmailValidator;
|
||||||
use Da\User\Validator\TwoFactorTextMessageValidator;
|
use pcrt\User\Validator\TwoFactorTextMessageValidator;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\InvalidParamException;
|
use yii\base\InvalidParamException;
|
||||||
use yii\base\Model;
|
use yii\base\Model;
|
||||||
@ -87,7 +87,7 @@ class LoginForm extends Model
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
*
|
||||||
* @throws \Da\TwoFA\Exception\InvalidSecretKeyException (only if package is being used)
|
* @throws \pcrt\TwoFA\Exception\InvalidSecretKeyException (only if package is being used)
|
||||||
*/
|
*/
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -9,10 +9,10 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Form;
|
namespace pcrt\User\Form;
|
||||||
|
|
||||||
use Da\User\Query\UserQuery;
|
use pcrt\User\Query\UserQuery;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
use pcrt\User\Traits\ContainerAwareTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Model;
|
use yii\base\Model;
|
||||||
|
|
||||||
|
|||||||
@ -9,11 +9,11 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Form;
|
namespace pcrt\User\Form;
|
||||||
|
|
||||||
use Da\User\Model\User;
|
use pcrt\User\Model\User;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
use pcrt\User\Traits\ContainerAwareTrait;
|
||||||
use Da\User\Traits\ModuleAwareTrait;
|
use pcrt\User\Traits\ModuleAwareTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Model;
|
use yii\base\Model;
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
|
|||||||
@ -9,9 +9,9 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Form;
|
namespace pcrt\User\Form;
|
||||||
|
|
||||||
use Da\User\Query\UserQuery;
|
use pcrt\User\Query\UserQuery;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Model;
|
use yii\base\Model;
|
||||||
|
|
||||||
|
|||||||
@ -9,13 +9,13 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Form;
|
namespace pcrt\User\Form;
|
||||||
|
|
||||||
use Da\User\Factory\EmailChangeStrategyFactory;
|
use pcrt\User\Factory\EmailChangeStrategyFactory;
|
||||||
use Da\User\Helper\SecurityHelper;
|
use pcrt\User\Helper\SecurityHelper;
|
||||||
use Da\User\Model\User;
|
use pcrt\User\Model\User;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
use pcrt\User\Traits\ContainerAwareTrait;
|
||||||
use Da\User\Traits\ModuleAwareTrait;
|
use pcrt\User\Traits\ModuleAwareTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\InvalidConfigException;
|
use yii\base\InvalidConfigException;
|
||||||
use yii\base\InvalidParamException;
|
use yii\base\InvalidParamException;
|
||||||
|
|||||||
@ -9,11 +9,11 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Helper;
|
namespace pcrt\User\Helper;
|
||||||
|
|
||||||
use Da\User\Model\AbstractAuthItem;
|
use pcrt\User\Model\AbstractAuthItem;
|
||||||
use Da\User\Module;
|
use pcrt\User\Module;
|
||||||
use Da\User\Traits\AuthManagerAwareTrait;
|
use pcrt\User\Traits\AuthManagerAwareTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\helpers\ArrayHelper;
|
use yii\helpers\ArrayHelper;
|
||||||
use yii\rbac\Permission;
|
use yii\rbac\Permission;
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Helper;
|
namespace pcrt\User\Helper;
|
||||||
|
|
||||||
use yii\base\InvalidArgumentException;
|
use yii\base\InvalidArgumentException;
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Helper;
|
namespace pcrt\User\Helper;
|
||||||
|
|
||||||
class GravatarHelper
|
class GravatarHelper
|
||||||
{
|
{
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Helper;
|
namespace pcrt\User\Helper;
|
||||||
|
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Helper;
|
namespace pcrt\User\Helper;
|
||||||
|
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Exception;
|
use yii\base\Exception;
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Helper;
|
namespace pcrt\User\Helper;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use DateTimeZone;
|
use DateTimeZone;
|
||||||
|
|||||||
@ -9,9 +9,9 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Migration\Session;
|
namespace pcrt\User\Migration\Session;
|
||||||
|
|
||||||
use Da\User\Helper\MigrationHelper;
|
use pcrt\User\Helper\MigrationHelper;
|
||||||
use yii\db\Migration;
|
use yii\db\Migration;
|
||||||
|
|
||||||
class m000000_000001_create_session_history_table extends Migration
|
class m000000_000001_create_session_history_table extends Migration
|
||||||
|
|||||||
@ -9,9 +9,9 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Migration;
|
namespace pcrt\User\Migration;
|
||||||
|
|
||||||
use Da\User\Helper\MigrationHelper;
|
use pcrt\User\Helper\MigrationHelper;
|
||||||
use yii\db\Migration;
|
use yii\db\Migration;
|
||||||
|
|
||||||
class m000000_000001_create_user_table extends Migration
|
class m000000_000001_create_user_table extends Migration
|
||||||
|
|||||||
@ -9,9 +9,9 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Migration;
|
namespace pcrt\User\Migration;
|
||||||
|
|
||||||
use Da\User\Helper\MigrationHelper;
|
use pcrt\User\Helper\MigrationHelper;
|
||||||
use yii\db\Migration;
|
use yii\db\Migration;
|
||||||
|
|
||||||
class m000000_000002_create_profile_table extends Migration
|
class m000000_000002_create_profile_table extends Migration
|
||||||
|
|||||||
@ -9,9 +9,9 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Migration;
|
namespace pcrt\User\Migration;
|
||||||
|
|
||||||
use Da\User\Helper\MigrationHelper;
|
use pcrt\User\Helper\MigrationHelper;
|
||||||
use yii\db\Migration;
|
use yii\db\Migration;
|
||||||
|
|
||||||
class m000000_000003_create_social_account_table extends Migration
|
class m000000_000003_create_social_account_table extends Migration
|
||||||
|
|||||||
@ -9,9 +9,9 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Migration;
|
namespace pcrt\User\Migration;
|
||||||
|
|
||||||
use Da\User\Helper\MigrationHelper;
|
use pcrt\User\Helper\MigrationHelper;
|
||||||
use yii\db\Migration;
|
use yii\db\Migration;
|
||||||
|
|
||||||
class m000000_000004_create_token_table extends Migration
|
class m000000_000004_create_token_table extends Migration
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Migration;
|
namespace pcrt\User\Migration;
|
||||||
|
|
||||||
use yii\db\Migration;
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
|||||||
@ -9,9 +9,9 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Migration;
|
namespace pcrt\User\Migration;
|
||||||
|
|
||||||
use Da\User\Helper\MigrationHelper;
|
use pcrt\User\Helper\MigrationHelper;
|
||||||
use yii\db\Migration;
|
use yii\db\Migration;
|
||||||
|
|
||||||
class m000000_000006_add_two_factor_fields extends Migration
|
class m000000_000006_add_two_factor_fields extends Migration
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Migration;
|
namespace pcrt\User\Migration;
|
||||||
|
|
||||||
use yii\db\Migration;
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Migration;
|
namespace pcrt\User\Migration;
|
||||||
|
|
||||||
use yii\db\Migration;
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
|||||||
@ -9,9 +9,9 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Migration;
|
namespace pcrt\User\Migration;
|
||||||
|
|
||||||
use Da\User\Helper\MigrationHelper;
|
use pcrt\User\Helper\MigrationHelper;
|
||||||
use yii\db\Migration;
|
use yii\db\Migration;
|
||||||
|
|
||||||
class m000000_000009_add_gdpr_consent_fields extends Migration
|
class m000000_000009_add_gdpr_consent_fields extends Migration
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Migration;
|
namespace pcrt\User\Migration;
|
||||||
|
|
||||||
use yii\db\Migration;
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
|||||||
@ -9,11 +9,11 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Model;
|
namespace pcrt\User\Model;
|
||||||
|
|
||||||
use Da\User\Traits\AuthManagerAwareTrait;
|
use pcrt\User\Traits\AuthManagerAwareTrait;
|
||||||
use Da\User\Validator\RbacItemsValidator;
|
use pcrt\User\Validator\RbacItemsValidator;
|
||||||
use Da\User\Validator\RbacRuleExistsValidator;
|
use pcrt\User\Validator\RbacRuleExistsValidator;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Model;
|
use yii\base\Model;
|
||||||
use yii\rbac\Item;
|
use yii\rbac\Item;
|
||||||
|
|||||||
@ -9,10 +9,10 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Model;
|
namespace pcrt\User\Model;
|
||||||
|
|
||||||
use Da\User\Traits\AuthManagerAwareTrait;
|
use pcrt\User\Traits\AuthManagerAwareTrait;
|
||||||
use Da\User\Validator\RbacItemsValidator;
|
use pcrt\User\Validator\RbacItemsValidator;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\InvalidConfigException;
|
use yii\base\InvalidConfigException;
|
||||||
use yii\base\Model;
|
use yii\base\Model;
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Model;
|
namespace pcrt\User\Model;
|
||||||
|
|
||||||
use yii\rbac\Item;
|
use yii\rbac\Item;
|
||||||
|
|
||||||
|
|||||||
@ -9,13 +9,13 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Model;
|
namespace pcrt\User\Model;
|
||||||
|
|
||||||
use Da\User\Helper\GravatarHelper;
|
use pcrt\User\Helper\GravatarHelper;
|
||||||
use Da\User\Query\ProfileQuery;
|
use pcrt\User\Query\ProfileQuery;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
use pcrt\User\Traits\ContainerAwareTrait;
|
||||||
use Da\User\Traits\ModuleAwareTrait;
|
use pcrt\User\Traits\ModuleAwareTrait;
|
||||||
use Da\User\Validator\TimeZoneValidator;
|
use pcrt\User\Validator\TimeZoneValidator;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use DateTimeZone;
|
use DateTimeZone;
|
||||||
use Exception;
|
use Exception;
|
||||||
@ -27,6 +27,7 @@ use yii\db\ActiveRecord;
|
|||||||
/**
|
/**
|
||||||
* @property int $user_id
|
* @property int $user_id
|
||||||
* @property string $name
|
* @property string $name
|
||||||
|
* @property string $surname
|
||||||
* @property string $public_email
|
* @property string $public_email
|
||||||
* @property string $gravatar_email
|
* @property string $gravatar_email
|
||||||
* @property string $gravatar_id
|
* @property string $gravatar_id
|
||||||
@ -88,6 +89,7 @@ class Profile extends ActiveRecord
|
|||||||
'gravatarEmailPattern' => ['gravatar_email', 'email'],
|
'gravatarEmailPattern' => ['gravatar_email', 'email'],
|
||||||
'websiteUrl' => ['website', 'url'],
|
'websiteUrl' => ['website', 'url'],
|
||||||
'nameLength' => ['name', 'string', 'max' => 255],
|
'nameLength' => ['name', 'string', 'max' => 255],
|
||||||
|
'surnameLength' => ['surname', 'string', 'max' => 255],
|
||||||
'publicEmailLength' => ['public_email', 'string', 'max' => 255],
|
'publicEmailLength' => ['public_email', 'string', 'max' => 255],
|
||||||
'gravatarEmailLength' => ['gravatar_email', 'string', 'max' => 255],
|
'gravatarEmailLength' => ['gravatar_email', 'string', 'max' => 255],
|
||||||
'locationLength' => ['location', 'string', 'max' => 255],
|
'locationLength' => ['location', 'string', 'max' => 255],
|
||||||
@ -102,6 +104,7 @@ class Profile extends ActiveRecord
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => Yii::t('usuario', 'Name'),
|
'name' => Yii::t('usuario', 'Name'),
|
||||||
|
'surname' => Yii::t('usuario', 'Surname'),
|
||||||
'public_email' => Yii::t('usuario', 'Email (public)'),
|
'public_email' => Yii::t('usuario', 'Email (public)'),
|
||||||
'gravatar_email' => Yii::t('usuario', 'Gravatar email'),
|
'gravatar_email' => Yii::t('usuario', 'Gravatar email'),
|
||||||
'location' => Yii::t('usuario', 'Location'),
|
'location' => Yii::t('usuario', 'Location'),
|
||||||
@ -144,7 +147,7 @@ class Profile extends ActiveRecord
|
|||||||
*
|
*
|
||||||
* @return DateTime
|
* @return DateTime
|
||||||
*/
|
*/
|
||||||
public function getLocalTimeZone(DateTime $dateTime = null)
|
public function getLocalTimeZone(?DateTime $dateTime = null)
|
||||||
{
|
{
|
||||||
return $dateTime === null ? new DateTime() : $dateTime->setTimezone($this->getTimeZone());
|
return $dateTime === null ? new DateTime() : $dateTime->setTimezone($this->getTimeZone());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Model;
|
namespace pcrt\User\Model;
|
||||||
|
|
||||||
use yii\rbac\Item;
|
use yii\rbac\Item;
|
||||||
|
|
||||||
|
|||||||
@ -9,11 +9,11 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Model;
|
namespace pcrt\User\Model;
|
||||||
|
|
||||||
use Da\User\Traits\AuthManagerAwareTrait;
|
use pcrt\User\Traits\AuthManagerAwareTrait;
|
||||||
use Da\User\Validator\RbacRuleNameValidator;
|
use pcrt\User\Validator\RbacRuleNameValidator;
|
||||||
use Da\User\Validator\RbacRuleValidator;
|
use pcrt\User\Validator\RbacRuleValidator;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Model;
|
use yii\base\Model;
|
||||||
|
|
||||||
|
|||||||
@ -9,11 +9,11 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Model;
|
namespace pcrt\User\Model;
|
||||||
|
|
||||||
use Da\User\Module;
|
use pcrt\User\Module;
|
||||||
use Da\User\Query\SessionHistoryQuery;
|
use pcrt\User\Query\SessionHistoryQuery;
|
||||||
use Da\User\Traits\ModuleAwareTrait;
|
use pcrt\User\Traits\ModuleAwareTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\behaviors\TimestampBehavior;
|
use yii\behaviors\TimestampBehavior;
|
||||||
use yii\db\ActiveQuery;
|
use yii\db\ActiveQuery;
|
||||||
|
|||||||
@ -9,11 +9,11 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Model;
|
namespace pcrt\User\Model;
|
||||||
|
|
||||||
use Da\User\Query\SocialNetworkAccountQuery;
|
use pcrt\User\Query\SocialNetworkAccountQuery;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
use pcrt\User\Traits\ContainerAwareTrait;
|
||||||
use Da\User\Traits\ModuleAwareTrait;
|
use pcrt\User\Traits\ModuleAwareTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Exception;
|
use yii\base\Exception;
|
||||||
use yii\base\InvalidParamException;
|
use yii\base\InvalidParamException;
|
||||||
|
|||||||
@ -9,12 +9,12 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Model;
|
namespace pcrt\User\Model;
|
||||||
|
|
||||||
use Da\User\Helper\SecurityHelper;
|
use pcrt\User\Helper\SecurityHelper;
|
||||||
use Da\User\Query\TokenQuery;
|
use pcrt\User\Query\TokenQuery;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
use pcrt\User\Traits\ContainerAwareTrait;
|
||||||
use Da\User\Traits\ModuleAwareTrait;
|
use pcrt\User\Traits\ModuleAwareTrait;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
use yii\base\InvalidConfigException;
|
use yii\base\InvalidConfigException;
|
||||||
use yii\base\InvalidParamException;
|
use yii\base\InvalidParamException;
|
||||||
|
|||||||
@ -9,12 +9,12 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Model;
|
namespace pcrt\User\Model;
|
||||||
|
|
||||||
use Da\User\Helper\SecurityHelper;
|
use pcrt\User\Helper\SecurityHelper;
|
||||||
use Da\User\Query\UserQuery;
|
use pcrt\User\Query\UserQuery;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
use pcrt\User\Traits\ContainerAwareTrait;
|
||||||
use Da\User\Traits\ModuleAwareTrait;
|
use pcrt\User\Traits\ModuleAwareTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Exception;
|
use yii\base\Exception;
|
||||||
use yii\base\InvalidConfigException;
|
use yii\base\InvalidConfigException;
|
||||||
@ -57,7 +57,14 @@ use yii\web\IdentityInterface;
|
|||||||
* @property string $last_login_ip
|
* @property string $last_login_ip
|
||||||
* @property int $password_changed_at
|
* @property int $password_changed_at
|
||||||
* @property int $password_age
|
* @property int $password_age
|
||||||
* Defined relations:
|
* @property int $status
|
||||||
|
* @property string $password_reset_token
|
||||||
|
* @property string $language
|
||||||
|
* @property boolean $rememberMe
|
||||||
|
* @property int $state
|
||||||
|
* @property int $created_by
|
||||||
|
*
|
||||||
|
* Defined relations:
|
||||||
* @property SocialNetworkAccount[] $socialNetworkAccounts
|
* @property SocialNetworkAccount[] $socialNetworkAccounts
|
||||||
* @property Profile $profile
|
* @property Profile $profile
|
||||||
*/
|
*/
|
||||||
@ -204,6 +211,12 @@ class User extends ActiveRecord implements IdentityInterface
|
|||||||
'last_login_ip' => Yii::t('usuario', 'Last login IP'),
|
'last_login_ip' => Yii::t('usuario', 'Last login IP'),
|
||||||
'password_changed_at' => Yii::t('usuario', 'Last password change'),
|
'password_changed_at' => Yii::t('usuario', 'Last password change'),
|
||||||
'password_age' => Yii::t('usuario', 'Password age'),
|
'password_age' => Yii::t('usuario', 'Password age'),
|
||||||
|
'language' => Yii::t('usuario', 'Language'),
|
||||||
|
'status' => Yii::t('usuario', 'Status'),
|
||||||
|
'state' => Yii::t('usuario', 'State'),
|
||||||
|
'created_by' => Yii::t('usuario', 'Created by'),
|
||||||
|
'rememberMe' => Yii::t('usuario', 'Remember Me'),
|
||||||
|
'password_reset_token' => Yii::t('usuario', 'Password Reset Token'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,4 +406,40 @@ class User extends ActiveRecord implements IdentityInterface
|
|||||||
{
|
{
|
||||||
return $this->getAttribute('auth_tf_mobile_phone');
|
return $this->getAttribute('auth_tf_mobile_phone');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the user who created this user
|
||||||
|
* @return \yii\db\ActiveQuery
|
||||||
|
*/
|
||||||
|
public function getCreator()
|
||||||
|
{
|
||||||
|
return $this->hasOne(self::class, ['id' => 'created_by']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the user's name
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->profile ? $this->profile->name : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the user's surname
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getSurname()
|
||||||
|
{
|
||||||
|
return $this->profile ? $this->profile->surname : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the user's full name
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getFullName()
|
||||||
|
{
|
||||||
|
return $this->profile ? ($this->profile->name . ' ' . $this->profile->surname) : $this->username;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,10 +9,11 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User;
|
namespace pcrt\User;
|
||||||
|
|
||||||
use Da\User\Contracts\MailChangeStrategyInterface;
|
use pcrt\User\Contracts\MailChangeStrategyInterface;
|
||||||
use Da\User\Filter\AccessRuleFilter;
|
use pcrt\User\Controller\ProfileController;
|
||||||
|
use pcrt\User\Filter\AccessRuleFilter;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Module as BaseModule;
|
use yii\base\Module as BaseModule;
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
@ -90,7 +91,7 @@ class Module extends BaseModule
|
|||||||
* @see AccessRuleFilter
|
* @see AccessRuleFilter
|
||||||
*/
|
*/
|
||||||
public $gdprConsentExcludedUrls = [
|
public $gdprConsentExcludedUrls = [
|
||||||
'user/settings/*'
|
'user/profile/*'
|
||||||
];
|
];
|
||||||
/**
|
/**
|
||||||
* @var bool whether to enable two factor authentication or not
|
* @var bool whether to enable two factor authentication or not
|
||||||
@ -181,6 +182,12 @@ class Module extends BaseModule
|
|||||||
* @var string the administrator permission name
|
* @var string the administrator permission name
|
||||||
*/
|
*/
|
||||||
public $administratorPermissionName;
|
public $administratorPermissionName;
|
||||||
|
/**
|
||||||
|
* @var int $profileVisibility Defines the level of user's profile page visibility.
|
||||||
|
* Defaults to ProfileController::PROFILE_VISIBILITY_OWNER meaning no-one except the user itself can view
|
||||||
|
* the profile. @see ProfileController constants for possible options
|
||||||
|
*/
|
||||||
|
public $profileVisibility = ProfileController::PROFILE_VISIBILITY_OWNER;
|
||||||
/**
|
/**
|
||||||
* @var string the route prefix
|
* @var string the route prefix
|
||||||
*/
|
*/
|
||||||
@ -200,11 +207,11 @@ class Module extends BaseModule
|
|||||||
/**
|
/**
|
||||||
* @var string Web controller namespace
|
* @var string Web controller namespace
|
||||||
*/
|
*/
|
||||||
public $controllerNamespace = 'Da\User\Controller';
|
public $controllerNamespace = 'pcrt\User\Controller';
|
||||||
/**
|
/**
|
||||||
* @var string Console controller namespace
|
* @var string Console controller namespace
|
||||||
*/
|
*/
|
||||||
public $consoleControllerNamespace = 'Da\User\Command';
|
public $consoleControllerNamespace = 'pcrt\User\Command';
|
||||||
/**
|
/**
|
||||||
* @var array the class map. How the container should load specific classes
|
* @var array the class map. How the container should load specific classes
|
||||||
* @see Bootstrap::buildClassMap() for more details
|
* @see Bootstrap::buildClassMap() for more details
|
||||||
@ -219,12 +226,13 @@ class Module extends BaseModule
|
|||||||
'<action:(register|resend)>' => 'registration/<action>',
|
'<action:(register|resend)>' => 'registration/<action>',
|
||||||
'confirm/<id:\d+>/<code:[A-Za-z0-9_-]+>' => 'registration/confirm',
|
'confirm/<id:\d+>/<code:[A-Za-z0-9_-]+>' => 'registration/confirm',
|
||||||
'forgot' => 'recovery/request',
|
'forgot' => 'recovery/request',
|
||||||
|
'forgot/<email:[a-zA-Z0-9_.±]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+>' => 'recovery/request',
|
||||||
'recover/<id:\d+>/<code:[A-Za-z0-9_-]+>' => 'recovery/reset'
|
'recover/<id:\d+>/<code:[A-Za-z0-9_-]+>' => 'recovery/reset'
|
||||||
];
|
];
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $viewPath = '@Da/User/resources/views';
|
public $viewPath = '@pcrt/User/resources/views';
|
||||||
/**
|
/**
|
||||||
* @var string the session key name to impersonate users. Please, modify it for security reasons!
|
* @var string the session key name to impersonate users. Please, modify it for security reasons!
|
||||||
*/
|
*/
|
||||||
@ -241,10 +249,6 @@ class Module extends BaseModule
|
|||||||
* @var boolean whether to disable IP logging into user table
|
* @var boolean whether to disable IP logging into user table
|
||||||
*/
|
*/
|
||||||
public $disableIpLogging = false;
|
public $disableIpLogging = false;
|
||||||
/**
|
|
||||||
* @var boolean whether to disable viewing any user's profile for non-admin users
|
|
||||||
*/
|
|
||||||
public $disableProfileViewsForRegularUsers = false;
|
|
||||||
/**
|
/**
|
||||||
* @var array Minimum requirements when a new password is automatically generated.
|
* @var array Minimum requirements when a new password is automatically generated.
|
||||||
* Array structure: `requirement => minimum number characters`.
|
* Array structure: `requirement => minimum number characters`.
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Query;
|
namespace pcrt\User\Query;
|
||||||
|
|
||||||
use yii\db\ActiveQuery;
|
use yii\db\ActiveQuery;
|
||||||
|
|
||||||
|
|||||||
@ -9,9 +9,9 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Query;
|
namespace pcrt\User\Query;
|
||||||
|
|
||||||
use Da\User\Traits\ModuleAwareTrait;
|
use pcrt\User\Traits\ModuleAwareTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\web\Session;
|
use yii\web\Session;
|
||||||
|
|
||||||
|
|||||||
@ -9,9 +9,9 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Query;
|
namespace pcrt\User\Query;
|
||||||
|
|
||||||
use Da\User\Traits\ModuleAwareTrait;
|
use pcrt\User\Traits\ModuleAwareTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\db\ActiveQuery;
|
use yii\db\ActiveQuery;
|
||||||
|
|
||||||
|
|||||||
@ -9,9 +9,9 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Query;
|
namespace pcrt\User\Query;
|
||||||
|
|
||||||
use Da\User\Contracts\AuthClientInterface;
|
use pcrt\User\Contracts\AuthClientInterface;
|
||||||
use yii\db\ActiveQuery;
|
use yii\db\ActiveQuery;
|
||||||
|
|
||||||
class SocialNetworkAccountQuery extends ActiveQuery
|
class SocialNetworkAccountQuery extends ActiveQuery
|
||||||
|
|||||||
@ -9,9 +9,9 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Query;
|
namespace pcrt\User\Query;
|
||||||
|
|
||||||
use Da\User\Model\Token;
|
use pcrt\User\Model\Token;
|
||||||
use yii\db\ActiveQuery;
|
use yii\db\ActiveQuery;
|
||||||
|
|
||||||
class TokenQuery extends ActiveQuery
|
class TokenQuery extends ActiveQuery
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Query;
|
namespace pcrt\User\Query;
|
||||||
|
|
||||||
use yii\db\ActiveQuery;
|
use yii\db\ActiveQuery;
|
||||||
|
|
||||||
|
|||||||
@ -9,10 +9,10 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Search;
|
namespace pcrt\User\Search;
|
||||||
|
|
||||||
use Da\User\Traits\AuthManagerAwareTrait;
|
use pcrt\User\Traits\AuthManagerAwareTrait;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
use pcrt\User\Traits\ContainerAwareTrait;
|
||||||
use yii\base\Model;
|
use yii\base\Model;
|
||||||
use yii\data\ArrayDataProvider;
|
use yii\data\ArrayDataProvider;
|
||||||
use yii\db\Query;
|
use yii\db\Query;
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Search;
|
namespace pcrt\User\Search;
|
||||||
|
|
||||||
use yii\rbac\Item;
|
use yii\rbac\Item;
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Search;
|
namespace pcrt\User\Search;
|
||||||
|
|
||||||
use yii\rbac\Item;
|
use yii\rbac\Item;
|
||||||
|
|
||||||
|
|||||||
@ -9,10 +9,10 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Search;
|
namespace pcrt\User\Search;
|
||||||
|
|
||||||
use Da\User\Model\Rule;
|
use pcrt\User\Model\Rule;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
use pcrt\User\Traits\ContainerAwareTrait;
|
||||||
use yii\base\InvalidConfigException;
|
use yii\base\InvalidConfigException;
|
||||||
use yii\base\InvalidParamException;
|
use yii\base\InvalidParamException;
|
||||||
use yii\base\Model;
|
use yii\base\Model;
|
||||||
|
|||||||
@ -9,10 +9,10 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Search;
|
namespace pcrt\User\Search;
|
||||||
|
|
||||||
use Da\User\Model\SessionHistory;
|
use pcrt\User\Model\SessionHistory;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
use pcrt\User\Traits\ContainerAwareTrait;
|
||||||
use yii\base\InvalidConfigException;
|
use yii\base\InvalidConfigException;
|
||||||
use yii\base\InvalidParamException;
|
use yii\base\InvalidParamException;
|
||||||
use yii\data\ActiveDataProvider;
|
use yii\data\ActiveDataProvider;
|
||||||
|
|||||||
@ -9,11 +9,11 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Search;
|
namespace pcrt\User\Search;
|
||||||
|
|
||||||
use Da\User\Model\User;
|
use pcrt\User\Model\User;
|
||||||
use Da\User\Query\UserQuery;
|
use pcrt\User\Query\UserQuery;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
use pcrt\User\Traits\ContainerAwareTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\InvalidParamException;
|
use yii\base\InvalidParamException;
|
||||||
use yii\base\Model;
|
use yii\base\Model;
|
||||||
|
|||||||
@ -9,12 +9,12 @@
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Da\User\Service;
|
namespace pcrt\User\Service;
|
||||||
|
|
||||||
use Da\User\Contracts\ServiceInterface;
|
use pcrt\User\Contracts\ServiceInterface;
|
||||||
use Da\User\Model\Token;
|
use pcrt\User\Model\Token;
|
||||||
use Da\User\Model\User;
|
use pcrt\User\Model\User;
|
||||||
use Da\User\Query\TokenQuery;
|
use pcrt\User\Query\TokenQuery;
|
||||||
|
|
||||||
class AccountConfirmationService implements ServiceInterface
|
class AccountConfirmationService implements ServiceInterface
|
||||||
{
|
{
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user