fix logic bugs

This commit is contained in:
Antonio Ramirez
2017-06-15 01:27:19 +02:00
parent 6d1b01fc1c
commit 53a3a72cc5
3 changed files with 9 additions and 5 deletions

View File

@ -164,10 +164,11 @@ class AdminController extends Controller
{
/** @var User $user */
$user = $this->userQuery->where(['id' => $id])->one();
/** @var Profile $profile */
$profile = $user->profile;
if ($profile === null) {
$profile = $this->make(Profile::class);
$profile->link($user);
$profile->link('user', $user);
}
/** @var UserEvent $event */
$event = $this->make(UserEvent::class, [$user]);
@ -244,7 +245,7 @@ class AdminController extends Controller
public function actionDelete($id)
{
if ($id === Yii::$app->user->getId()) {
if ((int)$id === Yii::$app->user->getId()) {
Yii::$app->getSession()->setFlash('danger', Yii::t('usuario', 'You cannot remove your own account'));
} else {
/** @var User $user */
@ -269,7 +270,7 @@ class AdminController extends Controller
public function actionBlock($id)
{
if ($id === Yii::$app->user->getId()) {
if ((int)$id === Yii::$app->user->getId()) {
Yii::$app->getSession()->setFlash('danger', Yii::t('usuario', 'You cannot remove your own account'));
} else {
/** @var User $user */

View File

@ -64,10 +64,13 @@ class AuthItemEditionService implements ServiceInterface
$this->model->item = $item;
return $this->updateChildren();
$this->updateChildren();
} catch (Exception $e) {
return false;
}
return true;
}
/**

View File

@ -28,7 +28,7 @@ class UpdateAuthAssignmentsService implements ServiceInterface
public function run()
{
if ($this->model->validate()) {
if (!$this->model->validate()) {
return false;
}