一些微调

管理员登录后跳转位置恢复至与普通用户相同
This commit is contained in:
Chenx221 2024-04-21 16:40:37 +08:00
parent 3a081cad81
commit ffffaeebf4
Signed by: chenx221
GPG Key ID: D7A9EC07024C3021
2 changed files with 4 additions and 20 deletions

View File

@ -8,6 +8,6 @@ class TSParticlesAsset extends AssetBundle
{ {
public $sourcePath = '@npm/tsparticles--slim'; public $sourcePath = '@npm/tsparticles--slim';
public $js = [ public $js = [
'tsparticles.slim.bundle.js', 'tsparticles.slim.bundle.min.js',
]; ];
} }

View File

@ -256,12 +256,7 @@ class UserController extends Controller
} }
LoginLogs::addLog($user->id, Yii::$app->request->userIP, Yii::$app->request->userAgent, 1); //login success log LoginLogs::addLog($user->id, Yii::$app->request->userIP, Yii::$app->request->userAgent, 1); //login success log
Yii::$app->user->login($user, $model->rememberMe ? 3600 * 24 * 30 : 0); Yii::$app->user->login($user, $model->rememberMe ? 3600 * 24 * 30 : 0);
// user to home page, admin to admin/index return $this->goHome();
if (Yii::$app->user->can('admin')) {
return $this->redirect(['admin/index']);
} else {
return $this->goHome();
}
} }
} else { } else {
@ -317,11 +312,7 @@ class UserController extends Controller
LoginLogs::addLog($user->id, Yii::$app->request->userIP, Yii::$app->request->userAgent, 1); //login success log LoginLogs::addLog($user->id, Yii::$app->request->userIP, Yii::$app->request->userAgent, 1); //login success log
Yii::$app->user->login($user, $model->rememberMe ? 3600 * 24 * 30 : 0); Yii::$app->user->login($user, $model->rememberMe ? 3600 * 24 * 30 : 0);
Yii::$app->session->remove('login_verification'); Yii::$app->session->remove('login_verification');
if (Yii::$app->user->can('admin')) { return $this->goHome();
return $this->redirect(['admin/index']);
} else {
return $this->goHome();
}
} else { } else {
LoginLogs::addLog($user->id, Yii::$app->request->userIP, Yii::$app->request->userAgent, 0); //login failed log LoginLogs::addLog($user->id, Yii::$app->request->userIP, Yii::$app->request->userAgent, 0); //login failed log
Yii::$app->session->setFlash('error', '二步验证代码错误'); Yii::$app->session->setFlash('error', '二步验证代码错误');
@ -341,11 +332,7 @@ class UserController extends Controller
LoginLogs::addLog($user->id, Yii::$app->request->userIP, Yii::$app->request->userAgent, 1); //login success log LoginLogs::addLog($user->id, Yii::$app->request->userIP, Yii::$app->request->userAgent, 1); //login success log
Yii::$app->user->login($user, $model->rememberMe ? 3600 * 24 * 30 : 0); Yii::$app->user->login($user, $model->rememberMe ? 3600 * 24 * 30 : 0);
Yii::$app->session->remove('login_verification'); Yii::$app->session->remove('login_verification');
if (Yii::$app->user->can('admin')) { return $this->goHome();
return $this->redirect(['admin/index']);
} else {
return $this->goHome();
}
} else { } else {
LoginLogs::addLog($user->id, Yii::$app->request->userIP, Yii::$app->request->userAgent, 0); //login failed log LoginLogs::addLog($user->id, Yii::$app->request->userIP, Yii::$app->request->userAgent, 0); //login failed log
Yii::$app->session->setFlash('error', '恢复代码错误'); Yii::$app->session->setFlash('error', '恢复代码错误');
@ -928,9 +915,6 @@ class UserController extends Controller
LoginLogs::addLog($user->id, Yii::$app->request->userIP, Yii::$app->request->userAgent, 1); //login success log LoginLogs::addLog($user->id, Yii::$app->request->userIP, Yii::$app->request->userAgent, 1); //login success log
Yii::$app->user->login($user, $remember === 1 ? 3600 * 24 * 30 : 0); Yii::$app->user->login($user, $remember === 1 ? 3600 * 24 * 30 : 0);
$publicKeyCredentialSourceRepository1->saveCredential($publicKeyCredentialSource, '', false); $publicKeyCredentialSourceRepository1->saveCredential($publicKeyCredentialSource, '', false);
if (Yii::$app->user->can('admin')) {
return $this->asJson(['verified' => true, 'redirectTo' => 'index.php?r=admin%2Findex']);
}
return $this->asJson(['verified' => true, 'redirectTo' => 'index.php']); return $this->asJson(['verified' => true, 'redirectTo' => 'index.php']);
} }
// Optional, but highly recommended, you can save the credential source as it may be modified // Optional, but highly recommended, you can save the credential source as it may be modified