diff options
author | Marc Alexander <admin@m-a-styles.de> | 2019-08-10 21:23:54 +0200 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2019-08-10 21:30:40 +0200 |
commit | ba92e7d2d6fa946de715e3ff6b72275374824f8d (patch) | |
tree | adf19e2620d7783f8e3b77aee00029f400cb97bf /phpBB/phpbb | |
parent | fa5a0d5e210646d0d271f5ed7433e4cc028b5cf1 (diff) | |
download | forums-ba92e7d2d6fa946de715e3ff6b72275374824f8d.tar forums-ba92e7d2d6fa946de715e3ff6b72275374824f8d.tar.gz forums-ba92e7d2d6fa946de715e3ff6b72275374824f8d.tar.bz2 forums-ba92e7d2d6fa946de715e3ff6b72275374824f8d.tar.xz forums-ba92e7d2d6fa946de715e3ff6b72275374824f8d.zip |
[ticket/11327] Clean up code a bit
PHPBB3-11327
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r-- | phpBB/phpbb/ucp/controller/reset_password.php | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/phpBB/phpbb/ucp/controller/reset_password.php b/phpBB/phpbb/ucp/controller/reset_password.php index 679c659eb0..50d3ce91eb 100644 --- a/phpBB/phpbb/ucp/controller/reset_password.php +++ b/phpBB/phpbb/ucp/controller/reset_password.php @@ -13,6 +13,7 @@ namespace phpbb\ucp\controller; +use phpbb\auth\auth; use phpbb\config\config; use phpbb\controller\helper; use phpbb\db\driver\driver_interface; @@ -26,8 +27,7 @@ use phpbb\user; use Symfony\Component\HttpFoundation\Response; /** -* ucp_remind -* Sending password reminders +* Handling forgotten passwords via reset password functionality */ class reset_password { @@ -71,7 +71,7 @@ class reset_password protected $php_ext; /** - * ucp_remind constructor. + * Reset password controller constructor. * * @param config $config * @param driver_interface $db @@ -150,18 +150,18 @@ class reset_password $username = $this->request->variable('username', '', true); $email = strtolower($this->request->variable('email', '')); - add_form_key('ucp_remind'); + add_form_key('ucp_reset_password'); if ($submit) { - if (!check_form_key('ucp_remind')) + if (!check_form_key('ucp_reset_password')) { - trigger_error('FORM_INVALID'); + return $this->helper->message('FORM_INVALID'); } if (empty($email)) { - trigger_error('NO_EMAIL_USER'); + return $this->helper->message('NO_EMAIL_USER'); } $sql_array = [ @@ -211,27 +211,27 @@ class reset_password if (!$user_row) { - trigger_error($message); + return $this->helper->message($message); } if ($user_row['user_type'] == USER_IGNORE || $user_row['user_type'] == USER_INACTIVE) { - trigger_error($message); + return $this->helper->message($message); } // Do not create multiple valid reset tokens if (!empty($user_row['reset_token']) && (int) $user_row['reset_token_expiration'] >= time()) { - trigger_error($message); + return $this->helper->message($message); } // Check users permissions - $auth2 = new \phpbb\auth\auth(); + $auth2 = new auth(); $auth2->acl($user_row); if (!$auth2->acl_get('u_chgpasswd')) { - trigger_error($message); + return $this->helper->message($message); } // Generate reset token @@ -247,7 +247,10 @@ class reset_password WHERE user_id = ' . $user_row['user_id']; $this->db->sql_query($sql); - include_once($this->root_path . 'includes/functions_messenger.' . $this->php_ext); + if (!class_exists('messenger')) + { + include($this->root_path . 'includes/functions_messenger.' . $this->php_ext); + } /** @var \messenger $messenger */ $messenger = new \messenger(false); @@ -268,7 +271,7 @@ class reset_password $messenger->send($user_row['user_notify_type']); - trigger_error($message); + return $this->helper->message($message); } } @@ -278,7 +281,7 @@ class reset_password 'S_PROFILE_ACTION' => $this->helper->route('phpbb_ucp_forgot_password_controller'), ]); - return $this->helper->render('ucp_reset_password.html', $this->language->lang('UCP_REMIND')); + return $this->helper->render('ucp_reset_password.html', $this->language->lang('RESET_PASSWORD')); } /** @@ -304,7 +307,7 @@ class reset_password return $this->helper->message('NO_USER'); } - add_form_key('ucp_remind'); + add_form_key('ucp_reset_password'); $sql_array = [ 'SELECT' => 'user_id, username, user_permissions, user_email, user_jabber, user_notify_type, user_type,' @@ -357,7 +360,7 @@ class reset_password if ($submit) { - if (!check_form_key('ucp_remind')) + if (!check_form_key('ucp_reset_password')) { return $this->helper->message('FORM_INVALID'); } @@ -368,7 +371,7 @@ class reset_password } // Check users permissions - $auth2 = new \phpbb\auth\auth(); + $auth2 = new auth(); $auth2->acl($user_row); if (!$auth2->acl_get('u_chgpasswd')) @@ -414,7 +417,7 @@ class reset_password $user_row['username'] ]); meta_refresh(3, append_sid("{$this->root_path}index.{$this->php_ext}")); - trigger_error($this->language->lang('PASSWORD_RESET')); + return $this->helper->message($this->language->lang('PASSWORD_RESET')); } } @@ -428,6 +431,6 @@ class reset_password ]), ]); - return $this->helper->render('ucp_reset_password.html', $this->language->lang('UCP_REMIND')); + return $this->helper->render('ucp_reset_password.html', $this->language->lang('RESET_PASSWORD')); } } |