From 9f02aae4bcd8940358a793274dfdea5ec645a1b5 Mon Sep 17 00:00:00 2001 From: Rhilip Date: Sun, 21 Jul 2019 09:10:23 +0800 Subject: [PATCH] refactor(auth/error): merge `auth/error` page to `action/action_success` --- apps/components/User/UserTrait.php | 1 + apps/controllers/AuthController.php | 18 ++++++++---- apps/models/form/Auth/UserConfirmForm.php | 8 ++++++ apps/views/action/action_success.php | 4 +-- apps/views/auth/confirm_success.php | 35 ----------------------- apps/views/auth/error.php | 22 -------------- apps/views/error.php | 1 - 7 files changed, 23 insertions(+), 66 deletions(-) delete mode 100644 apps/views/auth/confirm_success.php delete mode 100644 apps/views/auth/error.php diff --git a/apps/components/User/UserTrait.php b/apps/components/User/UserTrait.php index d50ce33..f219d2f 100644 --- a/apps/components/User/UserTrait.php +++ b/apps/components/User/UserTrait.php @@ -49,6 +49,7 @@ trait UserTrait private $leechtime; private $invites; + private $temp_invites_details; protected $peer_status; protected $infoCacheKey; diff --git a/apps/controllers/AuthController.php b/apps/controllers/AuthController.php index 33bc227..e530f64 100644 --- a/apps/controllers/AuthController.php +++ b/apps/controllers/AuthController.php @@ -24,7 +24,7 @@ public function actionRegister() $register_form->setData(app()->request->post()); $success = $register_form->validate(); if (!$success) { - return $this->render('auth/error', [ + return $this->render('action/action_fail', [ 'title' => 'Register Failed', 'msg' => $register_form->getError() ]); @@ -51,13 +51,16 @@ public function actionConfirm() $confirm->setData(app()->request->get()); $success = $confirm->validate(); if (!$success) { - return $this->render('auth/error', [ + return $this->render('action/action_fail', [ 'title' => 'Confirm Failed', 'msg' => $confirm->getError() ]); } else { $confirm->flush(); - return $this->render('auth/confirm_success', ['action' => $confirm->action]); + return $this->render('action/action_success', [ + 'notice' => $confirm->getConfirmMsg(), + 'redirect' => '/auth/login' + ]); } } @@ -68,7 +71,7 @@ public function actionRecover() $form->setData(app()->request->post()); $success = $form->validate(); if (!$success) { - return $this->render('auth/error', [ + return $this->render('action/action_fail', [ 'title' => 'Action Failed', 'msg' => $form->getError() ]); @@ -77,7 +80,7 @@ public function actionRecover() if ($flush === true) { return $this->render('auth/recover_next_step'); } else { - return $this->render('auth/error', [ + return $this->render('action/action_fail', [ 'title' => 'Confirm Failed', 'msg' => $flush ]); @@ -117,7 +120,10 @@ public function actionLogin() return app()->response->redirect($return_to); } else { - return $this->render('auth/error', ['title' => 'Login Failed', 'msg' => $success]); + return $this->render('action_fail', [ + 'title' => 'Login Failed', + 'msg' => $success + ]); } } } else { diff --git a/apps/models/form/Auth/UserConfirmForm.php b/apps/models/form/Auth/UserConfirmForm.php index cc10b14..ba77093 100644 --- a/apps/models/form/Auth/UserConfirmForm.php +++ b/apps/models/form/Auth/UserConfirmForm.php @@ -123,4 +123,12 @@ public function flush() return $this->flush_recover(); } } + + public function getConfirmMsg() { + if ($this->action == self::ACTION_REGISTER) { + return 'Your account is success Confirmed.'; // FIXME i18n + } elseif ($this->action == self::ACTION_RECOVER) { + return 'Your password has been reset and new password has been send to your email, Please find it and login.'; + } + } } diff --git a/apps/views/action/action_success.php b/apps/views/action/action_success.php index 7f85be2..1b237c8 100644 --- a/apps/views/action/action_success.php +++ b/apps/views/action/action_success.php @@ -12,7 +12,7 @@ * @var string $redirect */ -$redirect = $redirect ?? app()->request->fullUrl(); +$redirect = app()->session->get('redirect') ?? $redirect ?? app()->request->fullUrl(); ?> layout('layout/base'); ?> @@ -30,7 +30,7 @@ end(); ?> -start('script'); ?> +push('script'); ?> -end(); ?> diff --git a/apps/views/auth/error.php b/apps/views/auth/error.php deleted file mode 100644 index 38ce6bb..0000000 --- a/apps/views/auth/error.php +++ /dev/null @@ -1,22 +0,0 @@ - - -layout('layout/base') ?> - -start('title') ?>Authorization Pointend(); ?> - -start('container') ?> -
-

Opps~

-

-
-end(); ?> diff --git a/apps/views/error.php b/apps/views/error.php index a9a5041..7ab08be 100644 --- a/apps/views/error.php +++ b/apps/views/error.php @@ -25,7 +25,6 @@ - insert('layout/head'); ?> <?= config('base.site_name') ?> :: Error Page -- Powered by <?= config('base.site_generator') ?>