Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Commit

Permalink
refactor(auth/error): merge auth/error page to action/action_success
Browse files Browse the repository at this point in the history
  • Loading branch information
Rhilip committed Jul 21, 2019
1 parent b54da2f commit 9f02aae
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 66 deletions.
1 change: 1 addition & 0 deletions apps/components/User/UserTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ trait UserTrait
private $leechtime;

private $invites;
private $temp_invites_details;

protected $peer_status;
protected $infoCacheKey;
Expand Down
18 changes: 12 additions & 6 deletions apps/controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
]);
Expand All @@ -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'
]);
}
}

Expand All @@ -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()
]);
Expand All @@ -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
]);
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 8 additions & 0 deletions apps/models/form/Auth/UserConfirmForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
}
}
}
4 changes: 2 additions & 2 deletions apps/views/action/action_success.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @var string $redirect
*/

$redirect = $redirect ?? app()->request->fullUrl();
$redirect = app()->session->get('redirect') ?? $redirect ?? app()->request->fullUrl();
?>

<?= $this->layout('layout/base'); ?>
Expand All @@ -30,7 +30,7 @@
</div>
<?php $this->end(); ?>

<?php $this->start('script'); ?>
<?php $this->push('script'); ?>
<script>
setTimeout(function () {
window.location = '<?= $this->e($redirect) ?>';
Expand Down
35 changes: 0 additions & 35 deletions apps/views/auth/confirm_success.php

This file was deleted.

22 changes: 0 additions & 22 deletions apps/views/auth/error.php

This file was deleted.

1 change: 0 additions & 1 deletion apps/views/error.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
<!DOCTYPE html>
<html lang="en">
<head>
<?php $this->insert('layout/head'); ?>

<title><?= config('base.site_name') ?> :: Error Page -- Powered by <?= config('base.site_generator') ?></title>

Expand Down

0 comments on commit 9f02aae

Please sign in to comment.