php-cs-fixer fix
This commit is contained in:
@ -280,7 +280,7 @@ class Bootstrap implements BootstrapInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes web url for rest routes.
|
* Initializes web url for rest routes.
|
||||||
* @param WebApplication $app
|
* @param WebApplication $app
|
||||||
* @throws InvalidConfigException
|
* @throws InvalidConfigException
|
||||||
*/
|
*/
|
||||||
protected function initUrlRestRoutes(WebApplication $app)
|
protected function initUrlRestRoutes(WebApplication $app)
|
||||||
|
|||||||
@ -1,5 +1,14 @@
|
|||||||
<?php
|
<?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\api\v1;
|
namespace Da\User\Controller\api\v1;
|
||||||
|
|
||||||
use Da\User\Event\UserEvent;
|
use Da\User\Event\UserEvent;
|
||||||
@ -58,10 +67,10 @@ class AdminController extends ActiveController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* AdminController constructor.
|
* AdminController constructor.
|
||||||
* @param string $id
|
* @param string $id
|
||||||
* @param Module $module
|
* @param Module $module
|
||||||
* @param UserQuery $userQuery
|
* @param UserQuery $userQuery
|
||||||
* @param array $config
|
* @param array $config
|
||||||
*/
|
*/
|
||||||
public function __construct($id, Module $module, UserQuery $userQuery, array $config = [])
|
public function __construct($id, Module $module, UserQuery $userQuery, array $config = [])
|
||||||
{
|
{
|
||||||
@ -87,30 +96,11 @@ class AdminController extends ActiveController
|
|||||||
{
|
{
|
||||||
// Get and then remove some default actions
|
// Get and then remove some default actions
|
||||||
$actions = parent::actions();
|
$actions = parent::actions();
|
||||||
unset($actions['create']);
|
unset($actions['create'], $actions['update'], $actions['delete']);
|
||||||
unset($actions['update']);
|
|
||||||
unset($actions['delete']);
|
|
||||||
return $actions;
|
return $actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function verbs()
|
|
||||||
{
|
|
||||||
// Get parent verbs
|
|
||||||
$verbs = parent::verbs();
|
|
||||||
|
|
||||||
// Add new verbs and return
|
|
||||||
$verbs['update-profile'] = ['PUT', 'PATCH'];
|
|
||||||
$verbs['assignments'] = ['GET'];
|
|
||||||
$verbs['confirm'] = ['PUT', 'PATCH'];
|
|
||||||
$verbs['block'] = ['PUT', 'PATCH'];
|
|
||||||
$verbs['password-reset'] = ['PUT', 'PATCH'];
|
|
||||||
$verbs['force-password-change'] = ['PUT', 'PATCH'];
|
|
||||||
return $verbs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -149,23 +139,23 @@ class AdminController extends ActiveController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override beforeAction. If the api is called with parameter username get the id of the user and set it in query params
|
* Override beforeAction. If the api is called with parameter username get the id of the user and set it in query params
|
||||||
|
* @param mixed $action
|
||||||
*/
|
*/
|
||||||
public function beforeAction($action)
|
public function beforeAction($action)
|
||||||
{
|
{
|
||||||
if($action == 'create'){
|
if ($action == 'create') {
|
||||||
return parent::beforeAction($action);
|
return parent::beforeAction($action);
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = Yii::$app->request->getQueryParam('id');
|
$id = Yii::$app->request->getQueryParam('id');
|
||||||
if(!is_null($id)){
|
if (!is_null($id)) {
|
||||||
return parent::beforeAction($action);
|
return parent::beforeAction($action);
|
||||||
}
|
}
|
||||||
|
|
||||||
$username = Yii::$app->request->getQueryParam('username');
|
$username = Yii::$app->request->getQueryParam('username');
|
||||||
if(is_null($username)){
|
if (is_null($username)) {
|
||||||
return parent::beforeAction($action);
|
return parent::beforeAction($action);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,8 +268,7 @@ class AdminController extends ActiveController
|
|||||||
if ($user->delete()) {
|
if ($user->delete()) {
|
||||||
$this->trigger(ActiveRecord::EVENT_AFTER_DELETE, $event);
|
$this->trigger(ActiveRecord::EVENT_AFTER_DELETE, $event);
|
||||||
Yii::$app->getResponse()->setStatusCode(204); // 204 = No Content
|
Yii::$app->getResponse()->setStatusCode(204); // 204 = No Content
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$this->throwServerError();
|
$this->throwServerError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -369,9 +358,8 @@ class AdminController extends ActiveController
|
|||||||
$this->trigger(UserEvent::EVENT_AFTER_CONFIRMATION, $event);
|
$this->trigger(UserEvent::EVENT_AFTER_CONFIRMATION, $event);
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$this->throwServerError();
|
$this->throwServerError();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -404,9 +392,8 @@ class AdminController extends ActiveController
|
|||||||
if ($this->make(UserBlockService::class, [$user, $event, $this])->run() || $user->hasErrors()) {
|
if ($this->make(UserBlockService::class, [$user, $event, $this])->run() || $user->hasErrors()) {
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$this->throwServerError();
|
$this->throwServerError();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -430,9 +417,8 @@ class AdminController extends ActiveController
|
|||||||
if ($this->make(PasswordRecoveryService::class, [$user->email, $mailService])->run()) {
|
if ($this->make(PasswordRecoveryService::class, [$user->email, $mailService])->run()) {
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$this->throwServerError();
|
$this->throwServerError();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -455,15 +441,32 @@ class AdminController extends ActiveController
|
|||||||
if ($this->make(PasswordExpireService::class, [$user])->run()) {
|
if ($this->make(PasswordExpireService::class, [$user])->run()) {
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$this->throwServerError();
|
$this->throwServerError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function verbs()
|
||||||
|
{
|
||||||
|
// Get parent verbs
|
||||||
|
$verbs = parent::verbs();
|
||||||
|
|
||||||
|
// Add new verbs and return
|
||||||
|
$verbs['update-profile'] = ['PUT', 'PATCH'];
|
||||||
|
$verbs['assignments'] = ['GET'];
|
||||||
|
$verbs['confirm'] = ['PUT', 'PATCH'];
|
||||||
|
$verbs['block'] = ['PUT', 'PATCH'];
|
||||||
|
$verbs['password-reset'] = ['PUT', 'PATCH'];
|
||||||
|
$verbs['force-password-change'] = ['PUT', 'PATCH'];
|
||||||
|
return $verbs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle server error (with default Yii2 response).
|
* Handle server error (with default Yii2 response).
|
||||||
* @return void
|
|
||||||
* @throws ServerErrorHttpException
|
* @throws ServerErrorHttpException
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function throwServerError()
|
protected function throwServerError()
|
||||||
{
|
{
|
||||||
@ -472,14 +475,11 @@ class AdminController extends ActiveController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle 404 error for user (usually if the entered ID is not valid).
|
* Handle 404 error for user (usually if the entered ID is not valid).
|
||||||
* @return void
|
|
||||||
* @throws NotFoundHttpException
|
* @throws NotFoundHttpException
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function throwUser404()
|
protected function throwUser404()
|
||||||
{
|
{
|
||||||
throw new NotFoundHttpException(Yii::t('usuario', 'User not found.'));
|
throw new NotFoundHttpException(Yii::t('usuario', 'User not found.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -188,9 +188,8 @@ class LoginForm extends Model
|
|||||||
return $this->user;
|
return $this->user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param IdentityInterface $user
|
* @param IdentityInterface $user
|
||||||
* @return User
|
* @return User
|
||||||
*/
|
*/
|
||||||
public function setUser(IdentityInterface $user)
|
public function setUser(IdentityInterface $user)
|
||||||
|
|||||||
@ -255,8 +255,8 @@ class Module extends BaseModule
|
|||||||
public $enableRestApi = false;
|
public $enableRestApi = false;
|
||||||
/**
|
/**
|
||||||
* @var string Which class to use as authenticator for REST API.
|
* @var string Which class to use as authenticator for REST API.
|
||||||
* Possible values: `HttpBasicAuth`, `HttpBearerAuth` or `QueryParamAuth`.
|
* Possible values: `HttpBasicAuth`, `HttpBearerAuth` or `QueryParamAuth`.
|
||||||
* Default value = `yii\filters\auth\QueryParamAuth` class, therefore access tokens are sent as query parameter; for instance: `https://example.com/users?access-token=xxxxxxxx`.
|
* Default value = `yii\filters\auth\QueryParamAuth` class, therefore access tokens are sent as query parameter; for instance: `https://example.com/users?access-token=xxxxxxxx`.
|
||||||
*/
|
*/
|
||||||
public $authenticatorClass = 'yii\filters\auth\QueryParamAuth';
|
public $authenticatorClass = 'yii\filters\auth\QueryParamAuth';
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user