aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/classes/ElggSite.php2
-rw-r--r--engine/lib/users.php60
-rw-r--r--pages/account/forgotten_password.php2
-rw-r--r--pages/account/reset_password.php35
-rw-r--r--views/default/core/account/login_walled_garden.php2
-rw-r--r--views/default/forms/login.php2
6 files changed, 58 insertions, 45 deletions
diff --git a/engine/classes/ElggSite.php b/engine/classes/ElggSite.php
index d3cb0d488..30b222c24 100644
--- a/engine/classes/ElggSite.php
+++ b/engine/classes/ElggSite.php
@@ -400,7 +400,7 @@ class ElggSite extends ElggEntity {
'action/login',
'register',
'action/register',
- 'pages/account/forgotten_password\.php',
+ 'forgotpassword',
'action/user/requestnewpassword',
'resetpassword',
'upgrade\.php',
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 832bcd529..8333888a2 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -748,40 +748,6 @@ function execute_new_password_request($user_guid, $conf_code) {
}
/**
- * Handles pages for password reset requests.
- *
- * @param array $page Pages array
- *
- * @return void
- */
-function elgg_user_resetpassword_page_handler($page) {
-
- $user_guid = get_input('u');
- $code = get_input('c');
-
- $user = get_entity($user_guid);
-
- // don't check code here to avoid automated attacks
- if (!$user instanceof ElggUser) {
- register_error(elgg_echo('user:passwordreset:unknown_user'));
- forward();
- }
-
- $params = array(
- 'guid' => $user_guid,
- 'code' => $code,
- );
- $form = elgg_view_form('user/passwordreset', array(), $params);
-
- $title = elgg_echo('resetpassword');
- $content = elgg_view_title(elgg_echo('resetpassword')) . $form;
-
- $body = elgg_view_layout('one_column', array('content' => $content));
-
- echo elgg_view_page($title, $body);
-}
-
-/**
* Simple function that will generate a random clear text password
* suitable for feeding into generate_user_password().
*
@@ -1129,14 +1095,27 @@ function collections_page_handler($page_elements) {
}
/**
- * Page handler for registration
+ * Page handler for account related pages
*
- * @param array $page_elements Page elements
+ * @param array $page_elements Page elements
+ * @param string $handler The handler string
*
* @return void
*/
-function registration_page_handler($page_elements) {
- require_once(dirname(dirname(dirname(__FILE__))) . "/pages/account/register.php");
+function elgg_user_account_page_handler($page_elements, $handler) {
+
+ $base_dir = elgg_get_root_path() . 'pages/account';
+ switch ($handler) {
+ case 'forgotpassword':
+ require_once("$base_dir/forgotten_password.php");
+ break;
+ case 'resetpassword':
+ require_once("$base_dir/reset_password.php");
+ break;
+ case 'register':
+ require_once("$base_dir/register.php");
+ break;
+ }
}
/**
@@ -1513,8 +1492,9 @@ function users_init() {
elgg_register_page_handler('friends', 'friends_page_handler');
elgg_register_page_handler('friendsof', 'friends_of_page_handler');
- elgg_register_page_handler('register', 'registration_page_handler');
- elgg_register_page_handler('resetpassword', 'elgg_user_resetpassword_page_handler');
+ elgg_register_page_handler('register', 'elgg_user_account_page_handler');
+ elgg_register_page_handler('forgotpassword', 'elgg_user_account_page_handler');
+ elgg_register_page_handler('resetpassword', 'elgg_user_account_page_handler');
elgg_register_page_handler('login', 'elgg_user_login_page_handler');
elgg_register_page_handler('avatar', 'elgg_avatar_page_handler');
elgg_register_page_handler('profile', 'elgg_profile_page_handler');
diff --git a/pages/account/forgotten_password.php b/pages/account/forgotten_password.php
index 93d786e22..7679eaa55 100644
--- a/pages/account/forgotten_password.php
+++ b/pages/account/forgotten_password.php
@@ -6,8 +6,6 @@
* @subpackage Registration
*/
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
if (elgg_is_logged_in()) {
forward();
}
diff --git a/pages/account/reset_password.php b/pages/account/reset_password.php
new file mode 100644
index 000000000..019ec3add
--- /dev/null
+++ b/pages/account/reset_password.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Page for resetting a forgotten password
+ *
+ * @package Elgg.Core
+ * @subpackage Registration
+ */
+
+if (elgg_is_logged_in()) {
+ forward();
+}
+
+$user_guid = get_input('u');
+$code = get_input('c');
+
+$user = get_entity($user_guid);
+
+// don't check code here to avoid automated attacks
+if (!$user instanceof ElggUser) {
+ register_error(elgg_echo('user:passwordreset:unknown_user'));
+ forward();
+}
+
+$params = array(
+ 'guid' => $user_guid,
+ 'code' => $code,
+);
+$form = elgg_view_form('user/passwordreset', array(), $params);
+
+$title = elgg_echo('resetpassword');
+$content = elgg_view_title(elgg_echo('resetpassword')) . $form;
+
+$body = elgg_view_layout('one_column', array('content' => $content));
+
+echo elgg_view_page($title, $body);
diff --git a/views/default/core/account/login_walled_garden.php b/views/default/core/account/login_walled_garden.php
index 9b5019096..1606b9592 100644
--- a/views/default/core/account/login_walled_garden.php
+++ b/views/default/core/account/login_walled_garden.php
@@ -6,7 +6,7 @@
*/
$reg_url = elgg_normalize_url('register');
-$forgot_url = elgg_normalize_url('pages/account/forgotten_password.php');
+$forgot_url = elgg_normalize_url('forgotpassword');
$cancel_button = elgg_view('input/button', array(
'value' => elgg_echo('cancel'),
'class' => 'elgg-button-cancel mlm',
diff --git a/views/default/forms/login.php b/views/default/forms/login.php
index 452c4c425..5cfdcd4c6 100644
--- a/views/default/forms/login.php
+++ b/views/default/forms/login.php
@@ -39,7 +39,7 @@
echo '<li><a class="registration_link" href="' . elgg_get_site_url() . 'register">' . elgg_echo('register') . '</a></li>';
}
?>
- <li><a class="forgotten_password_link" href="<?php echo elgg_get_site_url(); ?>pages/account/forgotten_password.php">
+ <li><a class="forgotten_password_link" href="<?php echo elgg_get_site_url(); ?>forgotpassword">
<?php echo elgg_echo('user:password:lost'); ?>
</a></li>
</ul> \ No newline at end of file