实现用户注册功能的启用/禁用

This commit is contained in:
Chenx221 2024-03-31 13:54:27 +08:00
parent a7dff15406
commit 83db8e3616
Signed by: chenx221
GPG Key ID: D7A9EC07024C3021

View File

@ -410,6 +410,11 @@ class UserController extends Controller
return $this->goHome(); return $this->goHome();
} }
if ($_ENV['REGISTRATION_ENABLED'] === 'false') {
Yii::$app->session->setFlash('error', '站点已关闭注册');
return $this->goHome();
}
$model = new User(['scenario' => 'register']); $model = new User(['scenario' => 'register']);
if ($model->load(Yii::$app->request->post()) && $model->validate()) { if ($model->load(Yii::$app->request->post()) && $model->validate()) {
// 根据 verifyProvider 的值选择使用哪种验证码服务 // 根据 verifyProvider 的值选择使用哪种验证码服务
@ -518,7 +523,7 @@ class UserController extends Controller
Yii::$app->session->setFlash('error', 'Failed to change password.'); Yii::$app->session->setFlash('error', 'Failed to change password.');
} }
} }
}else{ } else {
Yii::$app->session->setFlash('error', 'Failed to validate password.'); Yii::$app->session->setFlash('error', 'Failed to validate password.');
} }
if (Yii::$app->user->can('admin')) { if (Yii::$app->user->can('admin')) {