Skip to content
This repository was archived by the owner on Jan 28, 2024. It is now read-only.

Commit 099b1ce

Browse files
committed
[#178] handle new emailPasswordAuth parameter
1 parent 21d5cc6 commit 099b1ce

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

controllers/UsersController.php

+28
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ public function actionAuthorizeAuthClient()
152152
*/
153153
public function actionLogin()
154154
{
155+
if (empty(Yii::$app->params['emailPasswordAuth'])) {
156+
return $this->sendErrorResponse([], Yii::t('app', 'Email/Password authorization is disabled.'));
157+
}
158+
155159
$model = new LoginForm();
156160

157161
$model->load(Yii::$app->request->post());
@@ -171,6 +175,10 @@ public function actionLogin()
171175
*/
172176
public function actionRegister()
173177
{
178+
if (empty(Yii::$app->params['emailPasswordAuth'])) {
179+
return $this->sendErrorResponse([], Yii::t('app', 'Email/Password authorization is disabled.'));
180+
}
181+
174182
$model = new UserCreateForm(['scenario' => UserCreateForm::SCENARIO_REGULAR]);
175183

176184
$model->load(Yii::$app->request->post());
@@ -216,6 +224,10 @@ public function actionActivate()
216224
*/
217225
public function actionRequestPasswordReset()
218226
{
227+
if (empty(Yii::$app->params['emailPasswordAuth'])) {
228+
return $this->sendErrorResponse([], Yii::t('app', 'Email/Password authorization is disabled.'));
229+
}
230+
219231
$model = new UserPasswordResetRequestForm();
220232

221233
$model->load(Yii::$app->request->post());
@@ -236,6 +248,10 @@ public function actionRequestPasswordReset()
236248
*/
237249
public function actionConfirmPasswordReset()
238250
{
251+
if (empty(Yii::$app->params['emailPasswordAuth'])) {
252+
return $this->sendErrorResponse([], Yii::t('app', 'Email/Password authorization is disabled.'));
253+
}
254+
239255
$model = new UserPasswordResetForm();
240256

241257
$model->load(Yii::$app->request->post());
@@ -254,6 +270,10 @@ public function actionConfirmPasswordReset()
254270
*/
255271
public function actionRequestEmailChange()
256272
{
273+
if (empty(Yii::$app->params['emailPasswordAuth'])) {
274+
return $this->sendErrorResponse([], Yii::t('app', 'Email/Password authorization is disabled.'));
275+
}
276+
257277
$model = new UserEmailChangeRequestForm(Yii::$app->user->identity);
258278

259279
$model->load(Yii::$app->request->post());
@@ -274,6 +294,10 @@ public function actionRequestEmailChange()
274294
*/
275295
public function actionConfirmEmailChange()
276296
{
297+
if (empty(Yii::$app->params['emailPasswordAuth'])) {
298+
return $this->sendErrorResponse([], Yii::t('app', 'Email/Password authorization is disabled.'));
299+
}
300+
277301
try {
278302
$token = CastHelper::toString(Yii::$app->request->post('token'));
279303
$user = User::changeEmailByEmailChangeToken($token);
@@ -366,6 +390,10 @@ public function actionView($id)
366390
*/
367391
public function actionCreate()
368392
{
393+
if (empty(Yii::$app->params['emailPasswordAuth'])) {
394+
return $this->sendErrorResponse([], Yii::t('app', 'Email/Password authorization is disabled.'));
395+
}
396+
369397
$user = Yii::$app->user->identity;
370398
if (!$user->isSuperUser()) {
371399
throw new ForbiddenHttpException('You are not allowed to create user accounts.');

0 commit comments

Comments
 (0)