Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

New confirm password input on password reset page

givanzedbbfb9dd0a0
diff --git a/admin/controller/user/reset.php b/admin/controller/user/reset.php
index 9a46262..4a0b073 100755
--- a/admin/controller/user/reset.php
+++ b/admin/controller/user/reset.php
@@ -33,24 +33,32 @@ use function Vvveb\url;
#[\AllowDynamicProperties]
class Reset {
function reset() {
- $token = $this->request->get['token'] ?? false;
- $user = $this->request->get['user'] ?? false;
- $password = $this->request->post['password'] ?? false;
- $admin = [];
+ $token = $this->request->get['token'] ?? false;
+ $user = $this->request->get['user'] ?? false;
+ $password = $this->request->post['password'] ?? false;
+ $confirmPassword = $this->request->post['confirm_password'] ?? false;
+ $admin = [];
if ($user && $token) {
$admin = Admin::get(['username' => $user, 'token' => $token, 'status' => 1]);
- if ($password && $admin) {
- if (Admin::update(['token' => '', 'password' => $password], ['username' => $user, 'token' => $token])) {
- $success = __('Password was reset!');
- $this->view->success['login'] = $success;
- $this->session->set('success', ['login' => $success]);
- header('Location: ' . url(['module' => 'user/login'/*, 'success' => $success*/]));
+ if ($password) {
+ if ($confirmPassword && ($password === $confirmPassword)) {
+ if ($admin) {
+ if (Admin::update(['token' => '', 'password' => $password], ['username' => $user, 'token' => $token])) {
+ $success = __('Password was reset!');
+ $this->view->success['login'] = $success;
+ $this->session->set('success', ['login' => $success]);
+ header('Location: ' . url(['module' => 'user/login'/*, 'success' => $success*/]));
+ } else {
+ $errors = __('Update failed!');
+ $this->view->errors['login'] = $errors;
+ $this->session->set('errors', ['login' => $errors]);
+ }
+ }
} else {
- $errors = __('Update failed!');
+ $errors = __('Passwords don\'t match!');
$this->view->errors['login'] = $errors;
- $this->session->set('errors', ['login' => $errors]);
}
}
}
diff --git a/app/controller/user/reset.php b/app/controller/user/reset.php
index 5b40982..3662e2b 100644
--- a/app/controller/user/reset.php
+++ b/app/controller/user/reset.php
@@ -34,25 +34,33 @@ use function Vvveb\url;
#[\AllowDynamicProperties]
class Reset extends Base {
function reset() {
- $token = $this->request->get['token'] ?? false;
- $user = $this->request->get['user'] ?? false;
- $password = $this->request->post['password'] ?? false;
- $admin = [];
+ $token = $this->request->get['token'] ?? false;
+ $user = $this->request->get['user'] ?? false;
+ $password = $this->request->post['password'] ?? false;
+ $confirmPassword = $this->request->post['confirm_password'] ?? false;
+ $admin = [];
if ($user && $token) {
$admin = User::get(['user' => $user, 'token' => $token]);
- if ($password && $admin) {
- if (User::update(['token' => '', 'password' => $password], ['username' => $user, 'token' => $token])) {
- $success = __('Password was reset!');
- $this->view->success['login'] = $success;
- $this->session->set('success', ['login' => $success]);
- $this->redirect('/user/login');
- //header('Location: ' . url(['module' => 'user/login', 'success' => $success]));
+ if ($password) {
+ if ($confirmPassword && ($password === $confirmPassword)) {
+ if ($admin) {
+ if (User::update(['token' => '', 'password' => $password], ['username' => $user, 'token' => $token])) {
+ $success = __('Password was reset!');
+ $this->view->success['login'] = $success;
+ $this->session->set('success', ['login' => $success]);
+ $this->redirect('/user/login');
+ //header('Location: ' . url(['module' => 'user/login', 'success' => $success]));
+ } else {
+ $errors = __('Update failed!');
+ $this->view->errors['login'] = $errors;
+ $this->session->set('errors', ['login' => $errors]);
+ }
+ }
} else {
- $errors = __('Update failed!');
+ $errors = __('Passwords don\'t match!');
$this->view->errors['login'] = $errors;
- $this->session->set('errors', ['login' => $errors]);
}
}
}