From be5f38adea89bdb95be359aea3d97615b6b530a3 Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Sun, 31 Jan 2010 14:03:32 -0800
Subject: Minir l10n message cleanup. Avoid
in messages since the server
normalizes them to
, i.e. leading to a mismatch.
---
modules/gallery/views/upgrader.html.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
(limited to 'modules/gallery/views')
diff --git a/modules/gallery/views/upgrader.html.php b/modules/gallery/views/upgrader.html.php
index 6cf0068d..4490557c 100644
--- a/modules/gallery/views/upgrader.html.php
+++ b/modules/gallery/views/upgrader.html.php
@@ -112,7 +112,9 @@
else: // can_upgrade ?>
= t("Who are you?") ?>
- = t("You're not logged in as an administrator, so we have to verify you to make sure it's ok for you to do an upgrade. To prove you can run an upgrade, create a file called
%name in your gallery3/var/tmp directory.", array("name" => "$upgrade_token")) ?>
+ = t("You're not logged in as an administrator, so we have to verify you to make sure it's ok for you to do an upgrade. To prove you can run an upgrade, create a file called %name in your %tmp_dir_path directory.",
+ array("name" => "$upgrade_token",
+ "tmp_dir_path" => "gallery3/var/tmp")) ?>
">= t("Ok, I've done that") ?>
endif // can_upgrade ?>
--
cgit v1.2.3
From 163391ee391627f9c2b4eac359104809e2706a9b Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Sat, 6 Feb 2010 17:43:33 -0800
Subject: Partial fix for ticket 585: Require current password when changing an
account's email address.
Still leaving the user/group admin page wide open though.
---
modules/gallery/views/user_profile.html.php | 3 ++
modules/user/controllers/users.php | 70 ++++++++++++++++++++++++++---
2 files changed, 68 insertions(+), 5 deletions(-)
(limited to 'modules/gallery/views')
diff --git a/modules/gallery/views/user_profile.html.php b/modules/gallery/views/user_profile.html.php
index 78e1c579..1c3e4ea2 100644
--- a/modules/gallery/views/user_profile.html.php
+++ b/modules/gallery/views/user_profile.html.php
@@ -63,6 +63,9 @@
id}") ?>">
= t("Change password") ?>
+ id}") ?>">
+ = t("Change email") ?>
+
endif ?>
diff --git a/modules/user/controllers/users.php b/modules/user/controllers/users.php
index 166ff8b2..83adc354 100644
--- a/modules/user/controllers/users.php
+++ b/modules/user/controllers/users.php
@@ -28,7 +28,6 @@ class Users_Controller extends Controller {
try {
$valid = $form->validate();
$user->full_name = $form->edit_user->full_name->value;
- $user->email = $form->edit_user->email->value;
$user->url = $form->edit_user->url->value;
if ($user->locale != $form->edit_user->locale->value) {
@@ -97,6 +96,41 @@ class Users_Controller extends Controller {
}
}
+ public function change_email($id) {
+ $user = user::lookup($id);
+ if ($user->guest || $user->id != identity::active_user()->id) {
+ access::forbidden();
+ }
+
+ $form = $this->_get_change_email_form($user);
+ try {
+ $valid = $form->validate();
+ $user->email = $form->change_email->email->value;
+ $user->validate();
+ } catch (ORM_Validation_Exception $e) {
+ // Translate ORM validation errors into form error messages
+ foreach ($e->validation->errors() as $key => $error) {
+ $form->change_email->inputs[$key]->add_error($error, 1);
+ }
+ $valid = false;
+ }
+
+ if ($valid) {
+ $user->save();
+ module::event("user_change_email_form_completed", $user, $form);
+ message::success(t("Email address changed"));
+ module::event("user_login", $user); // since there's no user_authenticated event
+ print json_encode(
+ array("result" => "success",
+ "resource" => url::site("users/{$user->id}")));
+ } else {
+ log::warning("user", t("Failed email change for %name", array("name" => $user->name)));
+ $name = $user->name;
+ module::event("user_login_failed", $name);
+ print json_encode(array("result" => "error", "form" => (string) $form));
+ }
+ }
+
public function form_edit($id) {
$user = user::lookup($id);
if ($user->guest || $user->id != identity::active_user()->id) {
@@ -115,6 +149,15 @@ class Users_Controller extends Controller {
print $this->_get_change_password_form($user);
}
+ public function form_change_email($id) {
+ $user = user::lookup($id);
+ if ($user->guest || $user->id != identity::active_user()->id) {
+ access::forbidden();
+ }
+
+ print $this->_get_change_email_form($user);
+ }
+
private function _get_change_password_form($user) {
$form = new Forge(
"users/change_password/$user->id", "", "post", array("id" => "g-change-password-user-form"));
@@ -140,16 +183,33 @@ class Users_Controller extends Controller {
return $form;
}
+ private function _get_change_email_form($user) {
+ $form = new Forge(
+ "users/change_email/$user->id", "", "post", array("id" => "g-change-email-user-form"));
+ $group = $form->group("change_email")->label(t("Change your email address"));
+ $group->password("password")->label(t("Current password"))->id("g-password")
+ ->callback("auth::validate_too_many_failed_password_changes")
+ ->callback("user::valid_password")
+ ->error_messages("invalid", t("Incorrect password"))
+ ->error_messages(
+ "too_many_failed_password_changes",
+ t("Too many incorrect passwords. Try again later"));
+ $group->input("email")->label(t("New email address"))->id("g-email")->value($user->email)
+ ->error_messages("email", t("You must enter a valid email address"))
+ ->error_messages("length", t("Your email address is too long"))
+ ->error_messages("required", t("You must enter a valid email address"));
+
+ module::event("user_change_password_form", $user, $form);
+ $group->submit("")->value(t("Save"));
+ return $form;
+ }
+
private function _get_edit_form($user) {
$form = new Forge("users/update/$user->id", "", "post", array("id" => "g-edit-user-form"));
$group = $form->group("edit_user")->label(t("Edit your profile"));
$group->input("full_name")->label(t("Full Name"))->id("g-fullname")->value($user->full_name)
->error_messages("length", t("Your name is too long"));
self::_add_locale_dropdown($group, $user);
- $group->input("email")->label(t("Email"))->id("g-email")->value($user->email)
- ->error_messages("email", t("You must enter a valid email address"))
- ->error_messages("length", t("Your email address is too long"))
- ->error_messages("required", t("You must enter a valid email address"));
$group->input("url")->label(t("URL"))->id("g-url")->value($user->url);
module::event("user_edit_form", $user, $form);
--
cgit v1.2.3
From f93528ffab19b7a733fc8fb21c22853d8ec0d2f5 Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Sun, 7 Feb 2010 15:37:32 -0800
Subject: Last partial fix for ticket 585: Compartmentalize the admin area and
require active authentication every 20 minutes to access the admin area.
Also renaming auth::validate_too_many_failed_password_changes to validate_too_many_failed_auth_attempts since it's used in this generalized way in 3 places now.
---
modules/gallery/controllers/admin.php | 6 ++-
modules/gallery/controllers/reauthenticate.php | 72 ++++++++++++++++++++++++++
modules/gallery/helpers/auth.php | 27 +++++++++-
modules/gallery/helpers/gallery_event.php | 2 +
modules/gallery/views/reauthenticate.html.php | 10 ++++
modules/user/controllers/users.php | 8 +--
6 files changed, 118 insertions(+), 7 deletions(-)
create mode 100644 modules/gallery/controllers/reauthenticate.php
create mode 100644 modules/gallery/views/reauthenticate.html.php
(limited to 'modules/gallery/views')
diff --git a/modules/gallery/controllers/admin.php b/modules/gallery/controllers/admin.php
index e4216991..b5f3db39 100644
--- a/modules/gallery/controllers/admin.php
+++ b/modules/gallery/controllers/admin.php
@@ -21,7 +21,7 @@ class Admin_Controller extends Controller {
private $theme;
public function __construct($theme=null) {
- if (!(identity::active_user()->admin)) {
+ if (!identity::active_user()->admin) {
access::forbidden();
}
@@ -29,6 +29,10 @@ class Admin_Controller extends Controller {
}
public function __call($controller_name, $args) {
+ if (auth::must_reauth_for_admin_area()) {
+ return url::redirect("reauthenticate");
+ }
+
if (request::method() == "post") {
access::verify_csrf();
}
diff --git a/modules/gallery/controllers/reauthenticate.php b/modules/gallery/controllers/reauthenticate.php
new file mode 100644
index 00000000..4b88a9cc
--- /dev/null
+++ b/modules/gallery/controllers/reauthenticate.php
@@ -0,0 +1,72 @@
+admin) {
+ access::forbidden();
+ }
+ return self::_show_form(self::_form());
+ }
+
+ public function auth() {
+ if (!identity::active_user()->admin) {
+ access::forbidden();
+ }
+ access::verify_csrf();
+
+ $form = self::_form();
+ $valid = $form->validate();
+ $user = identity::active_user();
+ if ($valid) {
+ message::success(t("Successfully re-authenticated!"));
+ module::event("user_auth", $user);
+ url::redirect("admin");
+ } else {
+ $name = $user->name;
+ log::warning("user", t("Failed re-authentication for %name", array("name" => $name)));
+ module::event("user_auth_failed", $name);
+ return self::_show_form($form);
+ }
+ }
+
+ private static function _show_form($form) {
+ $view = new Theme_View("page.html", "other", "reauthenticate");
+ $view->page_title = t("Re-authenticate");
+ $view->content = new View("reauthenticate.html");
+ $view->content->form = $form;
+ $view->content->user_name = identity::active_user()->name;
+ print $view;
+ }
+
+ private static function _form() {
+ $form = new Forge("reauthenticate/auth", "", "post", array("id" => "g-reauthenticate-form"));
+ $form->set_attr('class', "g-narrow");
+ $group = $form->group("reauthenticate")->label(t("Re-authenticate"));
+ $group->password("password")->label(t("Password"))->id("g-password")->class(null)
+ ->callback("auth::validate_too_many_failed_auth_attempts")
+ ->callback("user::valid_password")
+ ->error_messages("invalid", t("Incorrect password"))
+ ->error_messages(
+ "too_many_failed_auth_attempts",
+ t("Too many incorrect passwords. Try again later"));
+ $group->submit("")->value(t("Submit"));
+ return $form;
+ }
+}
diff --git a/modules/gallery/helpers/auth.php b/modules/gallery/helpers/auth.php
index 2c1e3f67..c3e9e6e9 100644
--- a/modules/gallery/helpers/auth.php
+++ b/modules/gallery/helpers/auth.php
@@ -78,9 +78,9 @@ class auth_Core {
}
}
- static function validate_too_many_failed_password_changes($password_input) {
+ static function validate_too_many_failed_auth_attempts($form_input) {
if (self::too_many_failures(identity::active_user()->name)) {
- $password_input->add_error("too_many_failed_password_changes", 1);
+ $form_input->add_error("too_many_failed_auth_attempts", 1);
}
}
@@ -107,4 +107,27 @@ class auth_Core {
->where("name", "=", $user->name)
->delete_all();
}
+
+ /**
+ * Checks whether the current user (= admin) must
+ * actively re-authenticate before access is given
+ * to the admin area.
+ */
+ static function must_reauth_for_admin_area() {
+ if (!identity::active_user()->admin) {
+ access::forbidden();
+ }
+
+ $session = Session::instance();
+ $last_active_auth = $session->get("active_auth_timestamp", 0);
+ $last_admin_area_activity = $session->get("admin_area_activity_timestamp", 0);
+ $admin_area_timeout = module::get_var("gallery", "admin_area_timeout");
+
+ if (max($last_active_auth, $last_admin_area_activity) + $admin_area_timeout < time()) {
+ return true;
+ }
+
+ $session->set("admin_area_activity_timestamp", time());
+ return false;
+ }
}
\ No newline at end of file
diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php
index 5fa82160..63f33c12 100644
--- a/modules/gallery/helpers/gallery_event.php
+++ b/modules/gallery/helpers/gallery_event.php
@@ -110,6 +110,7 @@ class gallery_event_Core {
graphics::choose_default_toolkit();
module::clear_var("gallery", "choose_default_tookit");
}
+ Session::instance()->set("active_auth_timestamp", time());
auth::clear_failed_attempts($user);
}
@@ -119,6 +120,7 @@ class gallery_event_Core {
static function user_auth($user) {
auth::clear_failed_attempts($user);
+ Session::instance()->set("active_auth_timestamp", time());
}
static function item_index_data($item, $data) {
diff --git a/modules/gallery/views/reauthenticate.html.php b/modules/gallery/views/reauthenticate.html.php
new file mode 100644
index 00000000..8611d0f7
--- /dev/null
+++ b/modules/gallery/views/reauthenticate.html.php
@@ -0,0 +1,10 @@
+
+
+
+ = t("The administration session has expired, please re-authenticate to access the administration area.") ?>
+
+
+ = t("You are currently logged in as %user_name.", array("user_name" => $user_name)) ?>
+
+ = $form ?>
+
\ No newline at end of file
diff --git a/modules/user/controllers/users.php b/modules/user/controllers/users.php
index 1130852b..0730f391 100644
--- a/modules/user/controllers/users.php
+++ b/modules/user/controllers/users.php
@@ -164,11 +164,11 @@ class Users_Controller extends Controller {
"users/change_password/$user->id", "", "post", array("id" => "g-change-password-user-form"));
$group = $form->group("change_password")->label(t("Change your password"));
$group->password("old_password")->label(t("Old password"))->id("g-password")
- ->callback("auth::validate_too_many_failed_password_changes")
+ ->callback("auth::validate_too_many_failed_auth_attempts")
->callback("user::valid_password")
->error_messages("invalid", t("Incorrect password"))
->error_messages(
- "too_many_failed_password_changes",
+ "too_many_failed_auth_attempts",
t("Too many incorrect passwords. Try again later"));
$group->password("password")->label(t("New password"))->id("g-password")
->error_messages("min_length", t("Your new password is too short"));
@@ -189,11 +189,11 @@ class Users_Controller extends Controller {
"users/change_email/$user->id", "", "post", array("id" => "g-change-email-user-form"));
$group = $form->group("change_email")->label(t("Change your email address"));
$group->password("password")->label(t("Current password"))->id("g-password")
- ->callback("auth::validate_too_many_failed_password_changes")
+ ->callback("auth::validate_too_many_failed_auth_attempts")
->callback("user::valid_password")
->error_messages("invalid", t("Incorrect password"))
->error_messages(
- "too_many_failed_password_changes",
+ "too_many_failed_auth_attempts",
t("Too many incorrect passwords. Try again later"));
$group->input("email")->label(t("New email address"))->id("g-email")->value($user->email)
->error_messages("email", t("You must enter a valid email address"))
--
cgit v1.2.3
From 9695041a86ffeb1bfc5ced654cb04a9833eb9288 Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Sun, 7 Feb 2010 16:56:19 -0800
Subject: Change welcome message dialog to link to the user_profile page
instead of the change user dialog. a) the edit user form doesn't include the
password anymore b) the new admin would probably also like to change the
email, so directing him to the profile page with options to change the pw /
email.
Ideally, we'd have a special purpose edit profile page for the install experience, without prompting for the randomly generated password. But that's something for another task.
---
modules/gallery/views/welcome_message.html.php | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
(limited to 'modules/gallery/views')
diff --git a/modules/gallery/views/welcome_message.html.php b/modules/gallery/views/welcome_message.html.php
index 24d01bab..caeeff66 100644
--- a/modules/gallery/views/welcome_message.html.php
+++ b/modules/gallery/views/welcome_message.html.php
@@ -15,15 +15,12 @@
- id}") ?>"
+ id}") ?>"
title="= t("Edit your profile")->for_html_attr() ?>"
id="g-after-install-change-password-link"
class="g-button ui-state-default ui-corners-all">
- = t("Change password now") ?>
+ = t("Change password and email now") ?>
-
--
cgit v1.2.3
From 316b0583b374a5754ea112c00464d118917cdbc1 Mon Sep 17 00:00:00 2001
From: Tim Almdal
Date: Sun, 7 Feb 2010 21:38:51 -0800
Subject: Revert "Refactor the admin maintenance screen so that events are used
to populate the action buttons and other content such as the list of
scheduled tasks."
Leaving this api out of RC1.
This reverts commit 19fee6b5e4ceb8a5f90cafe4ad770856ece108ef.
Conflicts:
modules/gallery/views/admin_maintenance.html.php
---
modules/gallery/controllers/admin_maintenance.php | 11 ++---------
modules/gallery/views/admin_maintenance.html.php | 16 +++++++++-------
2 files changed, 11 insertions(+), 16 deletions(-)
(limited to 'modules/gallery/views')
diff --git a/modules/gallery/controllers/admin_maintenance.php b/modules/gallery/controllers/admin_maintenance.php
index 8e4845a9..487e77a6 100644
--- a/modules/gallery/controllers/admin_maintenance.php
+++ b/modules/gallery/controllers/admin_maintenance.php
@@ -44,17 +44,10 @@ class Admin_Maintenance_Controller extends Admin_Controller {
$view->content->task_definitions = task::get_definitions();
$view->content->running_tasks = ORM::factory("task")
->where("done", "=", 0)->order_by("updated", "DESC")->find_all();
+ $view->content->schedule_definitions =
+ module::is_active("scheduler") ? scheduler::get_definitions() : "";
$view->content->finished_tasks = ORM::factory("task")
->where("done", "=", 1)->order_by("updated", "DESC")->find_all();
- $task_buttons =
- new ArrayObject(array((object)array("text" => t("run"),
- "url" =>url::site("admin/maintenance/start"))));
- module::event("admin_maintenance_task_buttons", $task_buttons);
- $view->content->task_buttons = $task_buttons;
-
- $maintenance_content = new ArrayObject();
- module::event("admin_maintenance_content", $maintenance_content);
- $view->content->task_maintenance_content = $maintenance_content;
print $view;
}
diff --git a/modules/gallery/views/admin_maintenance.html.php b/modules/gallery/views/admin_maintenance.html.php
index 19375670..15d04caa 100644
--- a/modules/gallery/views/admin_maintenance.html.php
+++ b/modules/gallery/views/admin_maintenance.html.php
@@ -29,21 +29,23 @@
= $task->description ?>
|
- foreach ($task_buttons as $button): ?>
- url}/$task->callback?csrf=$csrf" ?>"
+ callback?csrf=$csrf") ?>"
class="g-dialog-link g-button ui-icon-left ui-state-default ui-corner-all">
- = html::clean($button->text) ?>
+ = t("run") ?>
- endforeach ?>
+ if (module::is_active("scheduler")): ?>
+ callback?csrf=$csrf") ?>"
+ class="g-dialog-link g-button ui-icon-left ui-state-default ui-corner-all">
+ = t("schedule") ?>
+
+ endif ?>
|
endforeach ?>
- foreach ($task_maintenance_content as $content): ?>
- = html::purify($content) ?>
- endforeach ?>
+ = $schedule_definitions ?>
if ($running_tasks->count()): ?>
--
cgit v1.2.3
From b8047db5393ddbe27d6ee391845802054b92bf79 Mon Sep 17 00:00:00 2001
From: Tim Almdal
Date: Sun, 7 Feb 2010 21:40:34 -0800
Subject: Revert "Add the scheduler component to the admin maintenance screen."
This reverts commit 48cb5021c6bd7e65a13a0ff50a9e76f72da7d3a1.
---
modules/gallery/controllers/admin_maintenance.php | 2 --
modules/gallery/views/admin_maintenance.html.php | 8 --------
2 files changed, 10 deletions(-)
(limited to 'modules/gallery/views')
diff --git a/modules/gallery/controllers/admin_maintenance.php b/modules/gallery/controllers/admin_maintenance.php
index 487e77a6..d90fe0ea 100644
--- a/modules/gallery/controllers/admin_maintenance.php
+++ b/modules/gallery/controllers/admin_maintenance.php
@@ -44,8 +44,6 @@ class Admin_Maintenance_Controller extends Admin_Controller {
$view->content->task_definitions = task::get_definitions();
$view->content->running_tasks = ORM::factory("task")
->where("done", "=", 0)->order_by("updated", "DESC")->find_all();
- $view->content->schedule_definitions =
- module::is_active("scheduler") ? scheduler::get_definitions() : "";
$view->content->finished_tasks = ORM::factory("task")
->where("done", "=", 1)->order_by("updated", "DESC")->find_all();
print $view;
diff --git a/modules/gallery/views/admin_maintenance.html.php b/modules/gallery/views/admin_maintenance.html.php
index 15d04caa..ac597715 100644
--- a/modules/gallery/views/admin_maintenance.html.php
+++ b/modules/gallery/views/admin_maintenance.html.php
@@ -33,20 +33,12 @@
class="g-dialog-link g-button ui-icon-left ui-state-default ui-corner-all">
= t("run") ?>
- if (module::is_active("scheduler")): ?>
- callback?csrf=$csrf") ?>"
- class="g-dialog-link g-button ui-icon-left ui-state-default ui-corner-all">
- = t("schedule") ?>
-
- endif ?>
endforeach ?>
- = $schedule_definitions ?>
-
if ($running_tasks->count()): ?>
= t("Running tasks") ?>
--
cgit v1.2.3
From 92c2dd61ffa2140ec484ede0b75bb10b35229e63 Mon Sep 17 00:00:00 2001
From: Chad Kieffer
Date: Tue, 9 Feb 2010 21:57:04 -0700
Subject: Formated upgrader for RTL languages. Closes ticket #883
---
modules/gallery/css/upgrader.css | 39 ++++++++++++++++++++++++++++-----
modules/gallery/views/upgrader.html.php | 4 ++--
2 files changed, 36 insertions(+), 7 deletions(-)
(limited to 'modules/gallery/views')
diff --git a/modules/gallery/css/upgrader.css b/modules/gallery/css/upgrader.css
index 73da0ff4..2b3b5afd 100644
--- a/modules/gallery/css/upgrader.css
+++ b/modules/gallery/css/upgrader.css
@@ -26,6 +26,12 @@ div#footer {
margin: 1em;
}
+table {
+ width: 600px;
+ margin-bottom: 10px;
+}
+
+th.name,
td.name {
text-align: left;
padding-left: 30px;
@@ -53,11 +59,6 @@ tr.upgradeable td.gallery {
color: #00d;
}
-table {
- width: 600px;
- margin-bottom: 10px;
-}
-
p {
font-size: .9em;
}
@@ -125,3 +126,31 @@ pre {
margin: 0px;
padding: 0px;
}
+
+.rtl {
+ direction: rtl;
+}
+
+.rtl th.name,
+.rtl td.name {
+ text-align: right;
+ padding-right: 30px;
+}
+
+
+.rtl li:before {
+ content: "";
+}
+
+.rtl li:after {
+ content: "\00BB \0020";
+}
+
+.rtl ul {
+ margin-right: 0;
+ padding-right: 0;
+}
+
+.rtl div#dialog a.close {
+ float: left;
+}
diff --git a/modules/gallery/views/upgrader.html.php b/modules/gallery/views/upgrader.html.php
index 4490557c..55731440 100644
--- a/modules/gallery/views/upgrader.html.php
+++ b/modules/gallery/views/upgrader.html.php
@@ -6,7 +6,7 @@
media="screen,print,projection" />
-
+ >

" />
@@ -59,7 +59,7 @@
">
- | = t("Module name") ?> |
+ = t("Module name") ?> |
= t("Installed version") ?> |
= t("Available version") ?> |
--
cgit v1.2.3