diff --git a/lib/User/Controller/SecurityController.php b/lib/User/Controller/SecurityController.php index 55b4eb2..589d4c5 100644 --- a/lib/User/Controller/SecurityController.php +++ b/lib/User/Controller/SecurityController.php @@ -135,7 +135,8 @@ class SecurityController extends Controller $this->make(SocialNetworkAuthenticateService::class, [$this, $this->action, $client])->run(); } - public function connect(AuthClientInterface $client) { + public function connect(AuthClientInterface $client) + { if (Yii::$app->user->isGuest) { Yii::$app->session->setFlash('danger', Yii::t('user', 'Something went wrong')); diff --git a/lib/User/Controller/SettingsController.php b/lib/User/Controller/SettingsController.php index e77cd5a..2eaba88 100644 --- a/lib/User/Controller/SettingsController.php +++ b/lib/User/Controller/SettingsController.php @@ -199,7 +199,7 @@ class SettingsController extends Controller public function actionDelete() { - if (!$this->module->enableAccountDelete) { + if (!$this->module->allowAccountDelete) { throw new NotFoundHttpException(\Yii::t('user', 'Not found')); } diff --git a/lib/User/Module.php b/lib/User/Module.php index df7fc9a..da417b1 100644 --- a/lib/User/Module.php +++ b/lib/User/Module.php @@ -26,6 +26,10 @@ class Module extends \yii\base\Module * @var bool whether to enable password recovery or not. */ public $allowPasswordRecovery = true; + /** + * @var bool Whether user can remove his account + */ + public $allowAccountDelete = false; /** * @var string the class name of the strategy class to handle user's email change. */ diff --git a/lib/User/Widget/ConnectWidget.php b/lib/User/Widget/ConnectWidget.php new file mode 100644 index 0000000..5514d79 --- /dev/null +++ b/lib/User/Widget/ConnectWidget.php @@ -0,0 +1,55 @@ +view); + if ($this->popupMode) { + Yii::$app->view->registerJs("\$('#" . $this->getId() . "').authchoice();"); + } + $this->options['id'] = $this->getId(); + echo Html::beginTag('div', $this->options); + } + + /** + * @inheritdoc + */ + public function createClientUrl($provider) + { + if ($this->isConnected($provider)) { + return Url::to(['/user/settings/disconnect', 'id' => $this->accounts[$provider->getId()]->id]); + } else { + return parent::createClientUrl($provider); + } + } + + /** + * Checks if provider already connected to user. + * + * @param ClientInterface $provider + * + * @return bool + */ + public function isConnected(ClientInterface $provider) + { + return $this->accounts != null && isset($this->accounts[$provider->getId()]); + } +} diff --git a/lib/User/Widget/LoginWidget.php b/lib/User/Widget/LoginWidget.php new file mode 100644 index 0000000..8bce6fe --- /dev/null +++ b/lib/User/Widget/LoginWidget.php @@ -0,0 +1,21 @@ +render( + 'login', + [ + 'model' => Yii::createObject(LoginForm::class) + ] + ); + } +} diff --git a/lib/User/resources/views/mail/confirmation.php b/lib/User/resources/views/mail/confirmation.php index 75ded1e..df27956 100644 --- a/lib/User/resources/views/mail/confirmation.php +++ b/lib/User/resources/views/mail/confirmation.php @@ -1,19 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.md - * file that was distributed with this source code. - */ - use yii\helpers\Html; /** - * @var dektrium\user\models\User $user - * @var dektrium\user\models\Token $token + * @var \Da\User\Model\User $user + * @var \Da\User\Model\Token $token */ ?>
diff --git a/lib/User/resources/views/mail/layouts/html.php b/lib/User/resources/views/mail/layouts/html.php index cd80b96..8981ab4 100644 --- a/lib/User/resources/views/mail/layouts/html.php +++ b/lib/User/resources/views/mail/layouts/html.php @@ -1,14 +1,4 @@ - * - * For the full copyright and license information, please view the LICENSE.md - * file that was distributed with this source code. - */ - /** * @var \yii\web\View $this * @var yii\mail\BaseMessage $content diff --git a/lib/User/resources/views/mail/layouts/text.php b/lib/User/resources/views/mail/layouts/text.php index 097eb30..43ce060 100644 --- a/lib/User/resources/views/mail/layouts/text.php +++ b/lib/User/resources/views/mail/layouts/text.php @@ -1,14 +1,4 @@ - * - * For the full copyright and license information, please view the LICENSE.md - * file that was distributed with this source code. - */ - /** * @var string $content main view render result */ diff --git a/lib/User/resources/views/mail/reconfirmation.php b/lib/User/resources/views/mail/reconfirmation.php index 312e166..02073c1 100644 --- a/lib/User/resources/views/mail/reconfirmation.php +++ b/lib/User/resources/views/mail/reconfirmation.php @@ -1,18 +1,8 @@ - * - * For the full copyright and license information, please view the LICENSE.md - * file that was distributed with this source code. - */ - use yii\helpers\Html; /** - * @var dektrium\user\models\Token $token + * @var \Da\User\Model\Token $token */ ?>
diff --git a/lib/User/resources/views/mail/recovery.php b/lib/User/resources/views/mail/recovery.php index a7aadb2..1a98f78 100644 --- a/lib/User/resources/views/mail/recovery.php +++ b/lib/User/resources/views/mail/recovery.php @@ -1,19 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.md - * file that was distributed with this source code. - */ - use yii\helpers\Html; /** - * @var dektrium\user\models\User $user - * @var dektrium\user\models\Token $token + * @var \Da\User\Model\User $user + * @var \Da\User\Model\Token $token */ ?>
diff --git a/lib/User/resources/views/mail/text/confirmation.php b/lib/User/resources/views/mail/text/confirmation.php index e2f7a38..e1d2daf 100644 --- a/lib/User/resources/views/mail/text/confirmation.php +++ b/lib/User/resources/views/mail/text/confirmation.php @@ -1,17 +1,8 @@ - * - * For the full copyright and license information, please view the LICENSE.md - * file that was distributed with this source code. - */ - /** - * @var dektrium\user\models\User $user - * @var dektrium\user\models\Token $token + * @var \Da\User\Model\User $user + * @var \Da\User\Model\Token $token */ ?> = Yii::t('user', 'Hello') ?>, diff --git a/lib/User/resources/views/mail/text/reconfirmation.php b/lib/User/resources/views/mail/text/reconfirmation.php index fdb6c64..6c5a388 100644 --- a/lib/User/resources/views/mail/text/reconfirmation.php +++ b/lib/User/resources/views/mail/text/reconfirmation.php @@ -1,16 +1,6 @@ - * - * For the full copyright and license information, please view the LICENSE.md - * file that was distributed with this source code. - */ - /** - * @var dektrium\user\models\Token $token + * @var \Da\User\Model\Token $token */ ?> = Yii::t('user', 'Hello') ?>, diff --git a/lib/User/resources/views/mail/text/recovery.php b/lib/User/resources/views/mail/text/recovery.php index 3ffec17..9be9cad 100644 --- a/lib/User/resources/views/mail/text/recovery.php +++ b/lib/User/resources/views/mail/text/recovery.php @@ -1,17 +1,7 @@ - * - * For the full copyright and license information, please view the LICENSE.md - * file that was distributed with this source code. - */ - /** - * @var dektrium\user\models\User $user - * @var dektrium\user\models\Token $token + * @var \Da\User\Model\User $user + * @var \Da\User\Model\Token $token */ ?> = Yii::t('user', 'Hello') ?>, diff --git a/lib/User/resources/views/mail/text/welcome.php b/lib/User/resources/views/mail/text/welcome.php index a9f208c..8cff168 100644 --- a/lib/User/resources/views/mail/text/welcome.php +++ b/lib/User/resources/views/mail/text/welcome.php @@ -1,32 +1,23 @@ - * - * For the full copyright and license information, please view the LICENSE.md - * file that was distributed with this source code. - */ - /** - * @var dektrium\user\models\User + * @var \Da\User\Model\User $user + * @var \Da\User\Model\Token $token + * @var \Da\User\Module $module */ ?> = Yii::t('user', 'Hello') ?>, = Yii::t('user', 'Your account on {0} has been created', Yii::$app->name) ?>. -enableGeneratingPassword): ?> -= Yii::t('user', 'We have generated a password for you') ?>: -= $user->password ?> +generatePasswords): ?> + = Yii::t('user', 'We have generated a password for you') ?>: + = $user->password ?> -= Yii::t('user', 'In order to complete your registration, please click the link below') ?>. - -= $token->url ?> - -= Yii::t('user', 'If you cannot click the link, please try pasting the text into your browser') ?>. + = Yii::t('user', 'In order to complete your registration, please click the link below') ?>. + = $token->url ?> + = Yii::t('user', 'If you cannot click the link, please try pasting the text into your browser') ?>. = Yii::t('user', 'If you did not make this request you can ignore this email') ?>. diff --git a/lib/User/resources/views/mail/welcome.php b/lib/User/resources/views/mail/welcome.php index 79da04e..1e708ac 100644 --- a/lib/User/resources/views/mail/welcome.php +++ b/lib/User/resources/views/mail/welcome.php @@ -1,21 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.md - * file that was distributed with this source code. - */ - use yii\helpers\Html; /** - * @var dektrium\user\Module $module - * @var dektrium\user\models\User $user - * @var dektrium\user\models\Token $token - * @var bool $showPassword + * @var \Da\User\Module $module + * @var \Da\User\Model\User $user + * @var \Da\User\Model\Token $token + * @var bool $showPassword */ ?> @@ -25,22 +15,22 @@ use yii\helpers\Html;
= Yii::t('user', 'Your account on {0} has been created', Yii::$app->name) ?>. - enableGeneratingPassword): ?> + generatePasswords): ?> = Yii::t('user', 'We have generated a password for you') ?>: = $user->password ?>
-- = Yii::t('user', 'In order to complete your registration, please click the link below') ?>. -
-- = Html::a(Html::encode($token->url), $token->url); ?> -
-- = Yii::t('user', 'If you cannot click the link, please try pasting the text into your browser') ?>. -
++ = Yii::t('user', 'In order to complete your registration, please click the link below') ?>. +
++ = Html::a(Html::encode($token->url), $token->url); ?> +
++ = Yii::t('user', 'If you cannot click the link, please try pasting the text into your browser') ?>. +
diff --git a/lib/User/resources/views/profile/show.php b/lib/User/resources/views/profile/show.php index 076ff3e..bdabcae 100644 --- a/lib/User/resources/views/profile/show.php +++ b/lib/User/resources/views/profile/show.php @@ -1,19 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE.md - * file that was distributed with this source code. - */ - use yii\helpers\Html; /** * @var \yii\web\View $this - * @var \dektrium\user\models\Profile $profile + * @var \Da\User\Model\Profile $profile */ $this->title = empty($profile->name) ? Html::encode($profile->user->username) : Html::encode($profile->name); @@ -32,15 +23,29 @@ $this->params['breadcrumbs'][] = $this->title;
= Html::encode($profile->bio) ?>
diff --git a/lib/User/resources/views/recovery/request.php b/lib/User/resources/views/recovery/request.php index 7635380..fce2d37 100644 --- a/lib/User/resources/views/recovery/request.php +++ b/lib/User/resources/views/recovery/request.php @@ -1,21 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE.md - * file that was distributed with this source code. - */ - use yii\helpers\Html; use yii\widgets\ActiveForm; -/* +/** * @var yii\web\View $this * @var yii\widgets\ActiveForm $form - * @var dektrium\user\models\RecoveryForm $model + * @var \Da\User\Form\RecoveryForm $model */ $this->title = Yii::t('user', 'Recover your password'); @@ -28,11 +18,13 @@ $this->params['breadcrumbs'][] = $this->title;= Html::a(Yii::t('user', 'Didn\'t receive confirmation message?'), ['/user/registration/resend']) ?>
@@ -85,8 +78,10 @@ $this->params['breadcrumbs'][] = $this->title; = Html::a(Yii::t('user', 'Don\'t have an account? Sign up!'), ['/user/registration/register']) ?> - = Connect::widget([ - 'baseAuthUrl' => ['/user/security/auth'], - ]) ?> + = Connect::widget( + [ + 'baseAuthUrl' => ['/user/security/auth'], + ] + ) ?> diff --git a/lib/User/resources/views/settings/_menu.php b/lib/User/resources/views/settings/_menu.php index 71554ee..b0faa38 100644 --- a/lib/User/resources/views/settings/_menu.php +++ b/lib/User/resources/views/settings/_menu.php @@ -1,18 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE.md - * file that was distributed with this source code. - */ - use yii\helpers\Html; use yii\widgets\Menu; -/** @var dektrium\user\models\User $user */ +/** @var \Da\User\Model\User $user */ $user = Yii::$app->user->identity; $networksVisible = count(Yii::$app->authClientCollection->clients) > 0; @@ -21,27 +12,32 @@ $networksVisible = count(Yii::$app->authClientCollection->clients) > 0;= Yii::t('user', 'You can connect multiple accounts to be able to log in using them') ?>.