Merge remote-tracking branch 'upstream/master' into 1fa-channels-email-sms
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/**
|
||||
* This file is part of the 2amigos/yii2-usuario project.
|
||||
*
|
||||
* (c) 2amigOS! <http://2amigos.us/>
|
||||
@ -124,7 +124,7 @@ class SettingsController extends Controller
|
||||
'allow' => true,
|
||||
'actions' => ['confirm'],
|
||||
'roles' => ['?', '@'],
|
||||
],
|
||||
]
|
||||
],
|
||||
],
|
||||
];
|
||||
@ -143,7 +143,11 @@ class SettingsController extends Controller
|
||||
$profile->link('user', Yii::$app->user->identity);
|
||||
}
|
||||
|
||||
/** @var ProfileEvent $event */
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @var ProfileEvent $event
|
||||
*/
|
||||
$event = $this->make(ProfileEvent::class, [$profile]);
|
||||
|
||||
$this->make(AjaxRequestModelValidator::class, [$profile])->validate();
|
||||
@ -175,9 +179,11 @@ class SettingsController extends Controller
|
||||
if (!$this->module->enableGdprCompliance) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
return $this->render('privacy', [
|
||||
return $this->render(
|
||||
'privacy', [
|
||||
'module' => $this->module
|
||||
]);
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -194,7 +200,11 @@ class SettingsController extends Controller
|
||||
if (!$this->module->enableGdprCompliance) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
/** @var GdprDeleteForm $form */
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @var GdprDeleteForm $form
|
||||
*/
|
||||
$form = $this->make(GdprDeleteForm::class);
|
||||
|
||||
$user = $form->getUser();
|
||||
@ -216,21 +226,25 @@ class SettingsController extends Controller
|
||||
$security = $this->make(SecurityHelper::class);
|
||||
$anonymReplacement = $this->module->gdprAnonymizePrefix . $user->id;
|
||||
|
||||
$user->updateAttributes([
|
||||
$user->updateAttributes(
|
||||
[
|
||||
'email' => $anonymReplacement . "@example.com",
|
||||
'username' => $anonymReplacement,
|
||||
'gdpr_deleted' => 1,
|
||||
'blocked_at' => time(),
|
||||
'auth_key' => $security->generateRandomString()
|
||||
]);
|
||||
$user->profile->updateAttributes([
|
||||
]
|
||||
);
|
||||
$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);
|
||||
|
||||
@ -239,14 +253,20 @@ class SettingsController extends Controller
|
||||
return $this->goHome();
|
||||
}
|
||||
|
||||
return $this->render('gdpr-delete', [
|
||||
return $this->render(
|
||||
'gdpr-delete', [
|
||||
'model' => $form,
|
||||
]);
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function actionGdprConsent()
|
||||
{
|
||||
/** @var User $user */
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @var User $user
|
||||
*/
|
||||
$user = Yii::$app->user->identity;
|
||||
if ($user->gdpr_consent) {
|
||||
return $this->redirect(['profile']);
|
||||
@ -254,30 +274,37 @@ class SettingsController extends Controller
|
||||
$model = new DynamicModel(['gdpr_consent']);
|
||||
$model->addRule('gdpr_consent', 'boolean');
|
||||
$model->addRule('gdpr_consent', 'default', ['value' => 0, 'skipOnEmpty' => false]);
|
||||
$model->addRule('gdpr_consent', 'compare', [
|
||||
$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([
|
||||
$user->updateAttributes(
|
||||
[
|
||||
'gdpr_consent' => 1,
|
||||
'gdpr_consent_date' => time(),
|
||||
]);
|
||||
]
|
||||
);
|
||||
return $this->redirect(['profile']);
|
||||
}
|
||||
|
||||
return $this->render('gdpr-consent', [
|
||||
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
|
||||
@ -322,7 +349,11 @@ class SettingsController extends Controller
|
||||
|
||||
public function actionAccount()
|
||||
{
|
||||
/** @var SettingsForm $form */
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @var SettingsForm $form
|
||||
*/
|
||||
$form = $this->make(SettingsForm::class);
|
||||
$event = $this->make(UserEvent::class, [$form->getUser()]);
|
||||
|
||||
@ -389,7 +420,11 @@ class SettingsController extends Controller
|
||||
throw new NotFoundHttpException(Yii::t('usuario', 'Not found'));
|
||||
}
|
||||
|
||||
/** @var User $user */
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @var User $user
|
||||
*/
|
||||
$user = Yii::$app->user->identity;
|
||||
$event = $this->make(UserEvent::class, [$user]);
|
||||
Yii::$app->user->logout();
|
||||
@ -436,7 +471,11 @@ class SettingsController extends Controller
|
||||
{
|
||||
Yii::$app->response->format = Response::FORMAT_JSON;
|
||||
|
||||
/** @var User $user */
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @var User $user
|
||||
*/
|
||||
$user = $this->userQuery->whereId($id)->one();
|
||||
|
||||
if (null === $user) {
|
||||
@ -466,9 +505,13 @@ class SettingsController extends Controller
|
||||
|
||||
public function actionTwoFactorDisable($id)
|
||||
{
|
||||
/** @var User $user */
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @var User $user
|
||||
*/
|
||||
$user = $this->userQuery->whereId($id)->one();
|
||||
|
||||
|
||||
if (null === $user) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
@ -487,7 +530,7 @@ class SettingsController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param $id
|
||||
* @throws ForbiddenHttpException
|
||||
* @throws NotFoundHttpException
|
||||
* @throws \Exception
|
||||
@ -496,7 +539,11 @@ class SettingsController extends Controller
|
||||
*/
|
||||
protected function disconnectSocialNetwork($id)
|
||||
{
|
||||
/** @var SocialNetworkAccount $account */
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @var SocialNetworkAccount $account
|
||||
*/
|
||||
$account = $this->socialNetworkAccountQuery->whereId($id)->one();
|
||||
|
||||
if ($account === null) {
|
||||
|
||||
Reference in New Issue
Block a user