Code Duplication    Length = 16-17 lines in 2 locations

modules/user/controllers/AuthController.php 1 location

@@ 248-264 (lines=17) @@
245
     * @throws BadRequestHttpException
246
     * @throws ServerErrorHttpException
247
     */
248
    public function actionForgotPassword()
249
    {
250
        if (!$hash = Yii::$app->request->get('hash')) {
251
            throw new BadRequestHttpException();
252
        }
253
        if (!$user = User::findByHash($hash)) {
254
            throw new ServerErrorHttpException('The server encountered an internal error and could not complete your request.');
255
        }
256
        $changePasswordForm = new ChangePasswordForm();
257
        if ($user->changePassword($changePasswordForm)) {
258
            $user->login();
259
            return $this->goHome();
260
        }
261
        return $this->render('forgot-password', [
262
            'model' => $changePasswordForm,
263
        ]);
264
    }
265
}
266

modules/user/controllers/DefaultController.php 1 location

@@ 141-156 (lines=16) @@
138
     * @throws BadRequestHttpException
139
     * @throws ServerErrorHttpException
140
     */
141
    public function actionChangePassword()
142
    {
143
        if (!$hash = Yii::$app->request->get('hash')) {
144
            throw new BadRequestHttpException();
145
        }
146
        if (!$user = User::findByHash($hash)) {
147
            throw new ServerErrorHttpException('The server encountered an internal error and could not complete your request.');
148
        }
149
        $changePasswordForm = new ChangePasswordForm();
150
        if ($user->changePassword($changePasswordForm)) {
151
            return $this->goHome();
152
        }
153
        return $this->render('change-password', [
154
            'model' => $changePasswordForm,
155
        ]);
156
    }
157
}
158