update folder location

This commit is contained in:
Antonio Ramirez
2017-01-11 21:31:42 +01:00
parent 1cb60f0740
commit 13255a5117
167 changed files with 4770 additions and 8 deletions

View File

@ -0,0 +1,48 @@
<?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\Command;
use Da\User\Query\UserQuery;
use Da\User\Service\UserConfirmationService;
use Da\User\Traits\ContainerAwareTrait;
use Yii;
use yii\base\Module;
use yii\console\Controller;
use yii\helpers\Console;
class ConfirmController extends Controller
{
use ContainerAwareTrait;
protected $userQuery;
public function __construct($id, Module $module, UserQuery $userQuery, array $config)
{
$this->userQuery = $userQuery;
parent::__construct($id, $module, $config);
}
public function actionIndex($usernameOrEmail)
{
$user = $this->userQuery->whereUsernameOrEmail($usernameOrEmail)->one();
if ($user === null) {
$this->stdout(Yii::t('usuario', 'User is not found')."\n", Console::FG_RED);
} else {
if ($this->make(UserConfirmationService::class, [$user])->run()) {
$this->stdout(Yii::t('usuario', 'User has been confirmed')."\n", Console::FG_GREEN);
} else {
$this->stdout(Yii::t('usuario', 'Error occurred while confirming user')."\n", Console::FG_RED);
}
}
}
}

View File

@ -0,0 +1,45 @@
<?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\Command;
use Da\User\Factory\MailFactory;
use Da\User\Model\User;
use Da\User\Service\UserCreateService;
use Da\User\Traits\ContainerAwareTrait;
use Yii;
use yii\console\Controller;
use yii\helpers\Console;
class CreateController extends Controller
{
use ContainerAwareTrait;
public function actionIndex($email, $username, $password = null)
{
$user = $this->make(
User::class,
['scenario' => 'create', 'email' => $email, 'username' => $username, 'password' => $password]
);
$mailService = MailFactory::makeWelcomeMailerService($user);
if ($this->make(UserCreateService::class, [$user, $mailService])->run()) {
$this->stdout(Yii::t('usuario', 'User has been created')."!\n", Console::FG_GREEN);
} else {
$this->stdout(Yii::t('usuario', 'Please fix following errors:')."\n", Console::FG_RED);
foreach ($user->errors as $errors) {
foreach ($errors as $error) {
$this->stdout(' - '.$error."\n", Console::FG_RED);
}
}
}
}
}

View File

@ -0,0 +1,45 @@
<?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\Command;
use Da\User\Query\UserQuery;
use Yii;
use yii\base\Module;
use yii\console\Controller;
use yii\helpers\Console;
class DeleteController extends Controller
{
protected $userQuery;
public function __construct($id, Module $module, UserQuery $userQuery, array $config)
{
$this->userQuery = $userQuery;
parent::__construct($id, $module, $config);
}
public function actionIndex($usernameOrEmail)
{
if ($this->confirm(Yii::t('usuario', 'Are you sure? Deleted user can not be restored'))) {
$user = $this->userQuery->whereUsernameOrEmail($usernameOrEmail)->one();
if ($user === null) {
$this->stdout(Yii::t('usuario', 'User is not found')."\n", Console::FG_RED);
} else {
if ($user->delete()) {
$this->stdout(Yii::t('usuario', 'User has been deleted')."\n", Console::FG_GREEN);
} else {
$this->stdout(Yii::t('usuario', 'Error occurred while deleting user')."\n", Console::FG_RED);
}
}
}
}
}

View File

@ -0,0 +1,50 @@
<?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\Command;
use Da\User\Model\User;
use Da\User\Query\UserQuery;
use Da\User\Service\ResetPasswordService;
use Da\User\Traits\ContainerAwareTrait;
use Yii;
use yii\base\Module;
use yii\console\Controller;
use yii\helpers\Console;
class PasswordController extends Controller
{
use ContainerAwareTrait;
protected $userQuery;
public function __construct($id, Module $module, UserQuery $userQuery, array $config)
{
$this->userQuery = $userQuery;
parent::__construct($id, $module, $config);
}
public function actionIndex($usernameOrEmail, $password)
{
/** @var User $user */
$user = $this->userQuery->whereUsernameOrEmail($usernameOrEmail)->one();
if ($user === null) {
$this->stdout(Yii::t('usuario', 'User is not found')."\n", Console::FG_RED);
} else {
if ($this->make(ResetPasswordService::class, [$password, $user])->run()) {
$this->stdout(Yii::t('usuario', 'Password has been changed')."\n", Console::FG_GREEN);
} else {
$this->stdout(Yii::t('usuario', 'Error occurred while changing password')."\n", Console::FG_RED);
}
}
}
}