public function actionForgetPwdConfirm($checkCode) { if (isset($checkCode) && !empty($checkCode)) { $emailModel = EmailCheckCodes::findOne(array("type" => EmailCheckCodes::TYPE_FORGET_PASSWORD, "check_code" => $checkCode)); if (!$emailModel) { throw new \yii\web\HttpException(400, "認證碼錯誤", $this->errorLayout); } else { $model = Member::findOne(array('id' => $emailModel->member_id)); if (!$model) { throw new \yii\web\HttpException(400, "查無對應帳號", $this->errorLayout); } $model->password = md5($emailModel->other); if (!$model->save()) { throw new \yii\web\HttpException(400, Yii::$app->tool->formatErrorMsg($model->getErrors()), $this->errorLayout); } else { EmailCheckCodes::deleteAll("member_id = '{$emailModel->member_id}'"); } } } else { throw new \yii\web\HttpException(400, "認證碼錯誤", $this->errorLayout); } $this->layout = false; Yii::$app->getSession()->setFlash('alert', "您的密碼已更新, 請使用新密碼進行登入"); return $this->redirect(["user/login"]); }