代码清理

This commit is contained in:
Chenx221 2024-04-22 14:37:03 +08:00
parent d0370d4f46
commit 20e25b7441
Signed by: chenx221
GPG Key ID: D7A9EC07024C3021
13 changed files with 9 additions and 23 deletions

View File

@ -257,7 +257,7 @@ class AdminController extends Controller
} }
} }
} }
$model->loadDefaultValues(true); $model->loadDefaultValues();
return $this->render('user_create', [ return $this->render('user_create', [
'model' => $model, 'model' => $model,
]); ]);
@ -303,7 +303,6 @@ class AdminController extends Controller
return 3; return 3;
} }
if ($user->deleteAccount($operation == 1)) { if ($user->deleteAccount($operation == 1)) {
$logout_result = '';
if ($operation == 0) { if ($operation == 0) {
AdminSword::forceUserLogout($id); AdminSword::forceUserLogout($id);
} }
@ -321,7 +320,7 @@ class AdminController extends Controller
{ {
try { try {
$user = $this->findModel($id); $user = $this->findModel($id);
} catch (NotFoundHttpException $e) { } catch (NotFoundHttpException) {
Yii::$app->session->setFlash('error', '用户不存在'); Yii::$app->session->setFlash('error', '用户不存在');
return $this->redirect(['user']); return $this->redirect(['user']);
} }
@ -331,11 +330,10 @@ class AdminController extends Controller
$user->recovery_codes = null; $user->recovery_codes = null;
$user->save(false); $user->save(false);
Yii::$app->session->setFlash('success', '二步验证已关闭'); Yii::$app->session->setFlash('success', '二步验证已关闭');
return $this->redirect(['user-view', 'id' => $id]);
} else { } else {
Yii::$app->session->setFlash('error', '二步验证未启用,无需关闭'); Yii::$app->session->setFlash('error', '二步验证未启用,无需关闭');
return $this->redirect(['user-view', 'id' => $id]);
} }
return $this->redirect(['user-view', 'id' => $id]);
} }
/** /**
@ -816,7 +814,7 @@ class AdminController extends Controller
* @param int $id 公告ID * @param int $id 公告ID
* @return Response * @return Response
* @throws NotFoundHttpException if the model cannot be found * @throws NotFoundHttpException if the model cannot be found
* @throws \Throwable * @throws Throwable
* @throws StaleObjectException * @throws StaleObjectException
*/ */
public function actionAnnouncementsDelete(int $id): Response public function actionAnnouncementsDelete(int $id): Response

View File

@ -6,7 +6,6 @@ use app\models\TicketReplies;
use app\models\Tickets; use app\models\Tickets;
use app\models\TicketsSearch; use app\models\TicketsSearch;
use Yii; use Yii;
use yii\db\StaleObjectException;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\web\Controller; use yii\web\Controller;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;

View File

@ -809,7 +809,6 @@ class UserController extends Controller
*/ */
public function actionRequestAssertionOptions(string $username = null): Response public function actionRequestAssertionOptions(string $username = null): Response
{ {
$user = null;
if ($username !== null) { if ($username !== null) {
$user = User::findOne(['username' => $username]); $user = User::findOne(['username' => $username]);
if ($user === null) { if ($user === null) {

View File

@ -2,7 +2,6 @@
namespace app\models; namespace app\models;
use Yii;
use yii\db\ActiveRecord; use yii\db\ActiveRecord;
/** /**

View File

@ -4,7 +4,6 @@ namespace app\models;
use yii\base\Model; use yii\base\Model;
use yii\data\ActiveDataProvider; use yii\data\ActiveDataProvider;
use app\models\Announcements;
/** /**
* AnnouncementsSearch represents the model behind the search form of `app\models\Announcements`. * AnnouncementsSearch represents the model behind the search form of `app\models\Announcements`.

View File

@ -74,7 +74,7 @@ class CollectionUploaded extends ActiveRecord
/** /**
* Gets query for [[User]]. * Gets query for [[User]].
* *
* @return \yii\db\ActiveQuery * @return ActiveQuery
*/ */
public function getUser() public function getUser()
{ {

View File

@ -2,7 +2,6 @@
namespace app\models; namespace app\models;
use Yii;
use yii\db\ActiveQuery; use yii\db\ActiveQuery;
use yii\db\ActiveRecord; use yii\db\ActiveRecord;

View File

@ -5,7 +5,6 @@ namespace app\models;
use Yii; use Yii;
use yii\base\Model; use yii\base\Model;
use yii\data\ActiveDataProvider; use yii\data\ActiveDataProvider;
use app\models\Tickets;
/** /**
* TicketsSearch represents the model behind the search form of `app\models\Tickets`. * TicketsSearch represents the model behind the search form of `app\models\Tickets`.
@ -45,7 +44,6 @@ class TicketsSearch extends Tickets
// add conditions that should always apply here // add conditions that should always apply here
$dataProvider = null;
if(Yii::$app->user->can('admin')) { if(Yii::$app->user->can('admin')) {
$dataProvider = new ActiveDataProvider([ $dataProvider = new ActiveDataProvider([
'query' => $query, 'query' => $query,

View File

@ -2,6 +2,7 @@
namespace app\models; namespace app\models;
use Exception;
use Yii; use Yii;
use yii\db\ActiveQuery; use yii\db\ActiveQuery;
use yii\db\ActiveRecord; use yii\db\ActiveRecord;
@ -300,7 +301,7 @@ class User extends ActiveRecord implements IdentityInterface
* @param $insert * @param $insert
* @param $changedAttributes * @param $changedAttributes
* @return void * @return void
* @throws \Exception * @throws Exception
*/ */
public function afterSave($insert, $changedAttributes): void public function afterSave($insert, $changedAttributes): void
{ {

View File

@ -2,7 +2,6 @@
use yii\grid\GridView; use yii\grid\GridView;
use yii\helpers\Html; use yii\helpers\Html;
use yii\helpers\Url;
use yii\web\JqueryAsset; use yii\web\JqueryAsset;
use yii\web\View; use yii\web\View;
use yii\web\YiiAsset; use yii\web\YiiAsset;

View File

@ -2,7 +2,6 @@
use app\assets\FontAwesomeAsset; use app\assets\FontAwesomeAsset;
use app\models\PublicKeyCredentialSourceRepository; use app\models\PublicKeyCredentialSourceRepository;
use app\models\User;
use app\utils\FileSizeHelper; use app\utils\FileSizeHelper;
use app\utils\IPLocation; use app\utils\IPLocation;
use kartik\editable\Editable; use kartik\editable\Editable;

View File

@ -3,9 +3,7 @@
use yii\bootstrap5\Html; use yii\bootstrap5\Html;
use yii\bootstrap5\ActiveForm; use yii\bootstrap5\ActiveForm;
use yii\helpers\Url; use yii\helpers\Url;
use yii\web\JqueryAsset;
use yii\web\View;
use yii\widgets\Pjax;
/** @var yii\web\View $this */ /** @var yii\web\View $this */
/** @var app\models\User $model */ /** @var app\models\User $model */

View File

@ -2,9 +2,7 @@
use yii\bootstrap5\Html; use yii\bootstrap5\Html;
use yii\bootstrap5\ActiveForm; use yii\bootstrap5\ActiveForm;
use yii\web\JqueryAsset;
use yii\web\View;
use yii\widgets\Pjax;
/** @var yii\web\View $this */ /** @var yii\web\View $this */
/** @var app\models\User $model */ /** @var app\models\User $model */