/** * Confirm email */ public function actionConfirm($key) { /** @var \amnah\yii2\user\models\UserKey $userKey */ /** @var \amnah\yii2\user\models\User $user */ // search for userKey $success = false; $userKey = Yii::$app->getModule("user")->model("UserKey"); $userKey = $userKey::findActiveByKey($key, [$userKey::TYPE_EMAIL_ACTIVATE, $userKey::TYPE_EMAIL_CHANGE]); if ($userKey) { // confirm user $user = Yii::$app->getModule("user")->model("User"); $user = $user::findOne($userKey->user_id); $user->confirm(); // add contact information to zoho invoices $resp = $this->addZoHoContact($user); $obj = json_decode($resp); // als er geen invoice kan worden aangemaakt verzend dan email. if (!isset($obj)) { $user->sendEmailWhenError($userKey, 'Er kan voor deze nieuwe aanmelder geen Invoice worden aangemaakt. Zie zoho'); //throw new NotFoundHttpException('Er kan geen inv. aangemaakt worden foutcode(zhinv)'); } else { $invoice = new UserInvoice(); $invoice->user_id = $user->id; $invoice->zoho_contact_id = $obj->contact->contact_id; $invoice->save(false); $activedays = new UserActivedays(); $activedays->user_id = $user->id; $activedays->save(false); } // consume userKey and set success $userKey->consume(); $success = $user->email; } // render return $this->render("confirm", ["userKey" => $userKey, "success" => $success]); }