fixed all tests
This commit is contained in:
@ -105,7 +105,7 @@ class AdminController extends Controller
|
||||
public function actionCreate()
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = $this->make(User::class, ['scenario' => 'create']);
|
||||
$user = $this->make(User::class, [], ['scenario' => 'create']);
|
||||
|
||||
/** @var UserEvent $event */
|
||||
$event = $this->make(UserEvent::class, [$user]);
|
||||
@ -168,7 +168,7 @@ class AdminController extends Controller
|
||||
$this->make(AjaxRequestModelValidator::class, [$user])->validate();
|
||||
|
||||
if ($profile->load(Yii::$app->request->post())) {
|
||||
if($profile->save()) {
|
||||
if ($profile->save()) {
|
||||
$this->trigger(UserEvent::EVENT_BEFORE_PROFILE_UPDATE, $event);
|
||||
Yii::$app->getSession()->setFlash('success', Yii::t('user', 'Profile details have been updated'));
|
||||
$this->trigger(UserEvent::EVENT_AFTER_PROFILE_UPDATE, $event);
|
||||
|
||||
@ -74,7 +74,7 @@ class RecoveryController extends Controller
|
||||
}
|
||||
|
||||
/** @var RecoveryForm $form */
|
||||
$form = $this->make(RecoveryForm::class, ['scenario' => RecoveryForm::SCENARIO_REQUEST]);
|
||||
$form = $this->make(RecoveryForm::class, [], ['scenario' => RecoveryForm::SCENARIO_REQUEST]);
|
||||
|
||||
$event = $this->make(FormEvent::class, [$form]);
|
||||
|
||||
@ -87,6 +87,7 @@ class RecoveryController extends Controller
|
||||
$mailService = MailFactory::makeRecoveryMailerService($form->email);
|
||||
|
||||
if ($this->make(PasswordRecoveryService::class, [$form->email, $mailService])->run()) {
|
||||
|
||||
$this->trigger(FormEvent::EVENT_AFTER_REQUEST, $event);
|
||||
|
||||
return $this->render(
|
||||
@ -139,7 +140,7 @@ class RecoveryController extends Controller
|
||||
}
|
||||
|
||||
/** @var RecoveryForm $form */
|
||||
$form = $this->make(RecoveryForm::class, ['scenario' => RecoveryForm::SCENARIO_RESET]);
|
||||
$form = $this->make(RecoveryForm::class, [], ['scenario' => RecoveryForm::SCENARIO_RESET]);
|
||||
$event = $event->updateForm($form);
|
||||
|
||||
$this->make(AjaxRequestModelValidator::class, [$form])->validate();
|
||||
|
||||
@ -12,13 +12,11 @@ use Da\User\Model\User;
|
||||
use Da\User\Query\SocialNetworkAccountQuery;
|
||||
use Da\User\Query\UserQuery;
|
||||
use Da\User\Service\AccountConfirmationService;
|
||||
use Da\User\Service\EmailConfirmationService;
|
||||
use Da\User\Service\ResendConfirmationService;
|
||||
use Da\User\Service\UserConfirmationService;
|
||||
use Da\User\Service\UserCreateService;
|
||||
use Da\User\Service\UserRegisterService;
|
||||
use Da\User\Traits\ContainerTrait;
|
||||
use Da\User\Traits\ModuleTrait;
|
||||
use Da\User\Validator\AjaxRequestModelValidator;
|
||||
use Yii;
|
||||
use yii\base\Module;
|
||||
@ -81,7 +79,7 @@ class RegistrationController extends Controller
|
||||
|
||||
public function actionRegister()
|
||||
{
|
||||
if(!$this->module->enableRegistration) {
|
||||
if (!$this->module->enableRegistration) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
/** @var RegistrationForm $form */
|
||||
@ -91,14 +89,15 @@ class RegistrationController extends Controller
|
||||
|
||||
$this->make(AjaxRequestModelValidator::class, [$form])->validate();
|
||||
|
||||
if($form->load(Yii::$app->request->post()) && $form->validate()) {
|
||||
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
|
||||
$this->trigger(UserEvent::EVENT_BEFORE_REGISTER, $event);
|
||||
|
||||
$user = $this->make(User::class, [$form->attributes]);
|
||||
$user = $this->make(User::class, [], $form->attributes);
|
||||
$user->setScenario('register');
|
||||
$mailService = MailFactory::makeWelcomeMailerService($user);
|
||||
|
||||
if($this->make(UserRegisterService::class, [$user, $mailService])->run()) {
|
||||
if ($this->make(UserRegisterService::class, [$user, $mailService])->run()) {
|
||||
|
||||
Yii::$app->session->setFlash(
|
||||
'info',
|
||||
Yii::t(
|
||||
@ -106,16 +105,24 @@ class RegistrationController extends Controller
|
||||
'Your account has been created and a message with further instructions has been sent to your email'
|
||||
)
|
||||
);
|
||||
return $this->render('/shared/message', [
|
||||
'title' => Yii::t('user', 'Your account has been created')
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->render('register', [
|
||||
'model' => $form,
|
||||
'module' => $this->module,
|
||||
]);
|
||||
return $this->render(
|
||||
'/shared/message',
|
||||
[
|
||||
'title' => Yii::t('user', 'Your account has been created'),
|
||||
'module' => $this->module
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'register',
|
||||
[
|
||||
'model' => $form,
|
||||
'module' => $this->module,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function actionConnect($code)
|
||||
@ -206,29 +213,48 @@ class RegistrationController extends Controller
|
||||
$this->make(AjaxRequestModelValidator::class, [$form])->validate();
|
||||
|
||||
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
|
||||
$this->trigger(FormEvent::EVENT_BEFORE_RESEND, $event);
|
||||
/** @var User $user */
|
||||
$user = $this->userQuery->whereEmail($form->email)->one();
|
||||
$mailService = MailFactory::makeConfirmationMailerService($user);
|
||||
if ($this->make(ResendConfirmationService::class, [$user, $mailService])->run()) {
|
||||
$this->trigger(FormEvent::EVENT_AFTER_RESEND, $event);
|
||||
Yii::$app->session->setFlash(
|
||||
'info',
|
||||
Yii::t(
|
||||
'user',
|
||||
'A message has been sent to your email address. It contains a confirmation link that you must
|
||||
click to complete registration.'
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$success = true;
|
||||
if ($user !== null) {
|
||||
$this->trigger(FormEvent::EVENT_BEFORE_RESEND, $event);
|
||||
$mailService = MailFactory::makeConfirmationMailerService($user);
|
||||
if ($success = $this->make(ResendConfirmationService::class, [$user, $mailService])->run()) {
|
||||
$this->trigger(FormEvent::EVENT_AFTER_RESEND, $event);
|
||||
Yii::$app->session->setFlash(
|
||||
'info',
|
||||
Yii::t(
|
||||
'user',
|
||||
'A message has been sent to your email address. ' .
|
||||
'It contains a confirmation link that you must click to complete registration.'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
if ($user === null || $success === false) {
|
||||
Yii::$app->session->setFlash(
|
||||
'danger',
|
||||
Yii::t(
|
||||
'user',
|
||||
'We couldn\'t re-send the mail to confirm your address. Please, verify is the correct email.'
|
||||
'We couldn\'t re-send the mail to confirm your address. ' .
|
||||
'Please, verify is the correct email or if it has been confirmed already.'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $this->render('/shared/message', [
|
||||
'title' => $success
|
||||
? Yii::t('user', 'A new confirmation link has been sent')
|
||||
: Yii::t('user', 'Unable to send confirmation link'),
|
||||
'module' => $this->module,
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'resend',
|
||||
[
|
||||
'model' => $form,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,6 +126,7 @@ class SettingsController extends Controller
|
||||
|
||||
public function actionAccount()
|
||||
{
|
||||
/** @var SettingsForm $form */
|
||||
$form = $this->make(SettingsForm::class);
|
||||
$event = $this->make(FormEvent::class, [$form]);
|
||||
|
||||
@ -133,8 +134,9 @@ class SettingsController extends Controller
|
||||
|
||||
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('user', 'Your account details have been updated-'));
|
||||
Yii::$app->getSession()->setFlash('success', Yii::t('user', 'Your account details have been updated'));
|
||||
$this->trigger(UserEvent::EVENT_AFTER_ACCOUNT_UPDATE, $event);
|
||||
|
||||
return $this->refresh();
|
||||
|
||||
@ -29,7 +29,7 @@ class EmailChangeStrategyFactory
|
||||
public static function makeByStrategyType($strategy, SettingsForm $form)
|
||||
{
|
||||
if (array_key_exists($strategy, static::$map)) {
|
||||
return Yii::createObject(static::$map[$strategy], [$form]);
|
||||
return Yii::$container->get(static::$map[$strategy], [$form]);
|
||||
}
|
||||
|
||||
throw new Exception('Unknown strategy type');
|
||||
@ -42,7 +42,7 @@ class EmailChangeStrategyFactory
|
||||
*/
|
||||
public static function makeDefaultEmailChangeStrategy(SettingsForm $form)
|
||||
{
|
||||
return Yii::createObject(static::$map[MailChangeStrategyInterface::TYPE_DEFAULT], [$form]);
|
||||
return Yii::$container->get(static::$map[MailChangeStrategyInterface::TYPE_DEFAULT], [$form]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -52,7 +52,7 @@ class EmailChangeStrategyFactory
|
||||
*/
|
||||
public static function makeInsecureEmailChangeStrategy(SettingsForm $form)
|
||||
{
|
||||
return Yii::createObject(static::$map[MailChangeStrategyInterface::TYPE_INSECURE], [$form]);
|
||||
return Yii::$container->get(static::$map[MailChangeStrategyInterface::TYPE_INSECURE], [$form]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -62,6 +62,6 @@ class EmailChangeStrategyFactory
|
||||
*/
|
||||
public static function makeSecureEmailChangeStrategy(SettingsForm $form)
|
||||
{
|
||||
return Yii::createObject(static::$map[MailChangeStrategyInterface::TYPE_SECURE], [$form]);
|
||||
return Yii::$container->get(static::$map[MailChangeStrategyInterface::TYPE_SECURE], [$form]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,6 +109,6 @@ class MailFactory
|
||||
*/
|
||||
public static function makeMailerService($from, $to, $subject, $view, array $params = [])
|
||||
{
|
||||
return Yii::$container->get(MailService::class, [$from, $to, $subject, $view, $params]);
|
||||
return Yii::$container->get(MailService::class, [$from, $to, $subject, $view, $params, Yii::$app->getMailer()]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ class TokenFactory
|
||||
*/
|
||||
protected static function make($userId, $type)
|
||||
{
|
||||
return Yii::$container->get(Token::class, ['user_id' => $userId, 'type' => $type]);
|
||||
return Yii::createObject(['class' => Token::class, 'user_id' => $userId, 'type' => $type]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ class RecoveryForm extends Model
|
||||
* @param UserQuery $query
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct(UserQuery $query, array $config)
|
||||
public function __construct(UserQuery $query, array $config = [])
|
||||
{
|
||||
$this->query = $query;
|
||||
parent::__construct($config);
|
||||
|
||||
@ -37,9 +37,9 @@ class SettingsForm extends Model
|
||||
protected $securityHelper;
|
||||
|
||||
/** @var User */
|
||||
private $user;
|
||||
protected $user;
|
||||
|
||||
public function __construct(SecurityHelper $securityHelper, array $config)
|
||||
public function __construct(SecurityHelper $securityHelper, array $config = [])
|
||||
{
|
||||
$this->securityHelper = $securityHelper;
|
||||
parent::__construct($config);
|
||||
@ -62,16 +62,16 @@ class SettingsForm extends Model
|
||||
['email', 'username'],
|
||||
'unique',
|
||||
'when' => function ($model, $attribute) {
|
||||
return $this->user->$attribute != $model->$attribute;
|
||||
return $this->getUser()->$attribute != $model->$attribute;
|
||||
},
|
||||
'targetClass' => $this->getClassMap()[User::class]
|
||||
'targetClass' => $this->getClassMap()->get(User::class)
|
||||
],
|
||||
'newPasswordLength' => ['new_password', 'string', 'max' => 72, 'min' => 6],
|
||||
'currentPasswordRequired' => ['current_password', 'required'],
|
||||
'currentPasswordValidate' => [
|
||||
'current_password',
|
||||
function ($attribute) {
|
||||
if (!$this->securityHelper->validatePassword($this->$attribute, $this->user->password_hash)) {
|
||||
if (!$this->securityHelper->validatePassword($this->$attribute, $this->getUser()->password_hash)) {
|
||||
$this->addError($attribute, Yii::t('user', 'Current password is not valid'));
|
||||
}
|
||||
}
|
||||
@ -118,8 +118,6 @@ class SettingsForm extends Model
|
||||
if ($this->email == $this->user->email && $this->user->unconfirmed_email != null) {
|
||||
$this->user->unconfirmed_email = null;
|
||||
|
||||
return $this->user->save();
|
||||
|
||||
} elseif ($this->email != $this->user->email) {
|
||||
$strategy = EmailChangeStrategyFactory::makeByStrategyType(
|
||||
$this->getModule()->emailChangeStrategy,
|
||||
@ -129,6 +127,7 @@ class SettingsForm extends Model
|
||||
return $strategy->run();
|
||||
}
|
||||
|
||||
return $this->user->save();
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@ -39,7 +39,7 @@ class TokenQuery extends ActiveQuery
|
||||
*/
|
||||
public function whereIsConfirmationType()
|
||||
{
|
||||
return $this->andWhere(['type' => Token::TYPE_CONFIRM_NEW_EMAIL]);
|
||||
return $this->andWhere(['type' => Token::TYPE_CONFIRMATION]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
namespace Da\User\Service;
|
||||
|
||||
use Da\User\Contracts\ServiceInterface;
|
||||
use yii\swiftmailer\Mailer;
|
||||
use Yii;
|
||||
use yii\mail\BaseMailer;
|
||||
|
||||
class MailService implements ServiceInterface
|
||||
{
|
||||
@ -24,9 +24,9 @@ class MailService implements ServiceInterface
|
||||
* @param string $subject
|
||||
* @param string $view
|
||||
* @param array $params
|
||||
* @param Mailer $mailer
|
||||
* @param MailerInterface $mailer
|
||||
*/
|
||||
public function __construct($from, $to, $subject, $view, array $params, Mailer $mailer)
|
||||
public function __construct($from, $to, $subject, $view, array $params, BaseMailer $mailer)
|
||||
{
|
||||
$this->from = $from;
|
||||
$this->to = $to;
|
||||
@ -56,7 +56,8 @@ class MailService implements ServiceInterface
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
return $this->mailer->compose(['html' => $this->view, 'text' => "text/{$this->view}"], $this->params)
|
||||
return $this->mailer
|
||||
->compose(['html' => $this->view, 'text' => "text/{$this->view}"], $this->params)
|
||||
->setFrom($this->from)
|
||||
->setTo($this->to)
|
||||
->setSubject($this->subject)
|
||||
|
||||
@ -41,11 +41,15 @@ class PasswordRecoveryService implements ServiceInterface
|
||||
|
||||
$this->mailService->setViewParam('user', $user);
|
||||
$this->mailService->setViewParam('token', $token);
|
||||
|
||||
if (!$this->mailService->run()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Yii::$app->session->setFlash(
|
||||
'info',
|
||||
Yii::t('user', 'An email has been sent with instructions for resetting your password')
|
||||
);
|
||||
|
||||
return true;
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
@ -60,6 +60,7 @@ class UserCreateService implements ServiceInterface
|
||||
return true;
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
$transaction->rollBack();
|
||||
$this->logger->log($e->getMessage(), Logger::LEVEL_ERROR);
|
||||
|
||||
|
||||
@ -7,12 +7,14 @@ use Da\User\Factory\TokenFactory;
|
||||
use Da\User\Helper\SecurityHelper;
|
||||
use Da\User\Model\Token;
|
||||
use Da\User\Model\User;
|
||||
use Da\User\Traits\ModuleTrait;
|
||||
use yii\base\InvalidCallException;
|
||||
use yii\log\Logger;
|
||||
use Exception;
|
||||
|
||||
class UserRegisterService implements ServiceInterface
|
||||
{
|
||||
use ModuleTrait;
|
||||
|
||||
protected $model;
|
||||
protected $securityHelper;
|
||||
@ -38,8 +40,8 @@ class UserRegisterService implements ServiceInterface
|
||||
$transaction = $model->getDb()->beginTransaction();
|
||||
|
||||
try {
|
||||
$model->confirmed_at = $this->model->module->enableEmailConfirmation ? null : time();
|
||||
$model->password = $this->model->module->generatePasswords
|
||||
$model->confirmed_at = $this->getModule()->enableEmailConfirmation ? null : time();
|
||||
$model->password = $this->getModule()->generatePasswords
|
||||
? $this->securityHelper->generatePassword(8)
|
||||
: $model->password;
|
||||
|
||||
@ -50,7 +52,7 @@ class UserRegisterService implements ServiceInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
if($model->module->enableEmailConfirmation) {
|
||||
if($this->getModule()->enableEmailConfirmation) {
|
||||
$token = TokenFactory::makeConfirmationToken($model->id);
|
||||
}
|
||||
|
||||
|
||||
@ -29,13 +29,15 @@ trait ContainerTrait
|
||||
*
|
||||
* @param string $class he class name or an alias name (e.g. `foo`) that was previously registered via [[set()]]
|
||||
* or [[setSingleton()]].
|
||||
* @param array $params
|
||||
*
|
||||
* @param array $params constructor parameters
|
||||
* @param array $config attributes
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function make($class, $params = [])
|
||||
public function make($class, $params = [], $config = [])
|
||||
{
|
||||
return $this->getDi()->get($class, $params);
|
||||
return $this->getDi()->get($class, $params, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -38,7 +38,7 @@ class AssignmentsWidget extends Widget
|
||||
$model->updateAssignments();
|
||||
}
|
||||
|
||||
return $this->render('form', [
|
||||
return $this->render('/widgets/assignments/form', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ class LoginWidget extends Widget
|
||||
public function run()
|
||||
{
|
||||
return $this->render(
|
||||
'login',
|
||||
'/widgets/login',
|
||||
[
|
||||
'model' => Yii::createObject(LoginForm::class)
|
||||
]
|
||||
|
||||
@ -16,7 +16,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
|
||||
<?= $this->render(
|
||||
'/_alert',
|
||||
'/shared/_alert',
|
||||
[
|
||||
'module' => Yii::$app->getModule('user'),
|
||||
]
|
||||
|
||||
@ -18,7 +18,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
|
||||
<?= $this->render(
|
||||
'/_alert',
|
||||
'/shared/_alert',
|
||||
[
|
||||
'module' => Yii::$app->getModule('user'),
|
||||
]
|
||||
@ -75,7 +75,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
}
|
||||
},
|
||||
'format' => 'raw',
|
||||
'visible' => Yii::$app->getModule('user')->enableConfirmation,
|
||||
'visible' => Yii::$app->getModule('user')->enableEmailConfirmation,
|
||||
],
|
||||
[
|
||||
'header' => Yii::t('user', 'Block status'),
|
||||
|
||||
@ -17,7 +17,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
|
||||
<?= $this->render(
|
||||
'/_alert',
|
||||
'/shared/_alert',
|
||||
[
|
||||
'module' => Yii::$app->getModule('user'),
|
||||
]
|
||||
|
||||
@ -14,7 +14,7 @@ $this->title = Yii::t('user', 'Sign in');
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
|
||||
<?= $this->render('/_alert', ['module' => Yii::$app->getModule('user')]) ?>
|
||||
<?= $this->render('/shared/_alert', ['module' => Yii::$app->getModule('user')]) ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3">
|
||||
|
||||
@ -13,7 +13,7 @@ $this->title = Yii::t('user', 'Account settings');
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
|
||||
<?= $this->render('/_alert', ['module' => Yii::$app->getModule('user')]) ?>
|
||||
<?= $this->render('/shared/_alert', ['module' => Yii::$app->getModule('user')]) ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
|
||||
@ -13,7 +13,7 @@ $this->title = Yii::t('user', 'Networks');
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
|
||||
<?= $this->render('/_alert', ['module' => Yii::$app->getModule('user')]) ?>
|
||||
<?= $this->render('/shared/_alert', ['module' => Yii::$app->getModule('user')]) ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
|
||||
@ -21,7 +21,7 @@ $this->title = Yii::t('user', 'Profile settings');
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
|
||||
<?= $this->render('/_alert', ['module' => Yii::$app->getModule('user')]) ?>
|
||||
<?= $this->render('/shared/_alert', ['module' => Yii::$app->getModule('user')]) ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @var yii\web\View $this
|
||||
* @var \Da\User\Module $module
|
||||
* @var yii\web\View $this
|
||||
* @var \Da\User\Module $module
|
||||
* @var string $title
|
||||
*/
|
||||
|
||||
@ -10,6 +10,9 @@ $this->title = $title;
|
||||
|
||||
?>
|
||||
|
||||
<?= $this->render('_alert', [
|
||||
'module' => $module,
|
||||
]);
|
||||
<?= $this->render(
|
||||
'_alert',
|
||||
[
|
||||
'module' => $module,
|
||||
]
|
||||
);
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/*
|
||||
* This file is part of the Dektrium project
|
||||
*
|
||||
*
|
||||
* (c) Dektrium project <http://github.com/dektrium>
|
||||
*
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE.md
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
50
lib/User/resources/views/widgets/login/login.php
Normal file
50
lib/User/resources/views/widgets/login/login.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Dektrium project.
|
||||
*
|
||||
* (c) Dektrium project <http://github.com/dektrium>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE.md
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use yii\helpers\Url;
|
||||
use yii\widgets\ActiveForm;
|
||||
use yii\helpers\Html;
|
||||
|
||||
/**
|
||||
* @var yii\web\View $this
|
||||
* @var yii\widgets\ActiveForm $form
|
||||
* @var dektrium\user\models\LoginForm $model
|
||||
* @var string $action
|
||||
*/
|
||||
|
||||
?>
|
||||
|
||||
<?php if (Yii::$app->user->isGuest): ?>
|
||||
<?php $form = ActiveForm::begin([
|
||||
'id' => 'login-widget-form',
|
||||
'action' => Url::to(['/user/security/login']),
|
||||
'enableAjaxValidation' => true,
|
||||
'enableClientValidation' => false,
|
||||
'validateOnBlur' => false,
|
||||
'validateOnType' => false,
|
||||
'validateOnChange' => false,
|
||||
]) ?>
|
||||
|
||||
<?= $form->field($model, 'login')->textInput(['placeholder' => 'Login']) ?>
|
||||
|
||||
<?= $form->field($model, 'password')->passwordInput(['placeholder' => 'Password']) ?>
|
||||
|
||||
<?= $form->field($model, 'rememberMe')->checkbox() ?>
|
||||
|
||||
<?= Html::submitButton(Yii::t('user', 'Sign in'), ['class' => 'btn btn-primary btn-block']) ?>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
<?php else: ?>
|
||||
<?= Html::a(Yii::t('user', 'Logout'), ['/user/security/logout'], [
|
||||
'class' => 'btn btn-danger btn-block',
|
||||
'data-method' => 'post'
|
||||
]) ?>
|
||||
<?php endif ?>
|
||||
Reference in New Issue
Block a user