[Jifty-commit] jifty branch, master, updated. d2df60a13813a5c4745a8e8fd078d19a946399fa
Jifty commits
jifty-commit at lists.jifty.org
Thu May 13 12:37:19 EDT 2010
The branch, master has been updated
via d2df60a13813a5c4745a8e8fd078d19a946399fa (commit)
from 13fdf6c6ef5e04d1a2379660f92fd7cdb0784de5 (commit)
Summary of changes:
lib/Jifty/API.pm | 17 +++++++-----
lib/Jifty/Action/AboutMe.pm | 44 ++++++++++++++++++++++++++++++++
t/TestApp-Plugin-REST/t/02-basic-use.t | 3 +-
t/TestApp-Plugin-REST/t/03-format.t | 3 +-
4 files changed, 58 insertions(+), 9 deletions(-)
create mode 100644 lib/Jifty/Action/AboutMe.pm
- Log -----------------------------------------------------------------
commit d2df60a13813a5c4745a8e8fd078d19a946399fa
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Fri May 14 01:37:30 2010 +0900
Add an AboutMe action for dumping the CurrentUser
diff --git a/lib/Jifty/API.pm b/lib/Jifty/API.pm
index 509f34a..7e8c044 100644
--- a/lib/Jifty/API.pm
+++ b/lib/Jifty/API.pm
@@ -121,9 +121,10 @@ sub qualify {
=head2 reset
Resets which actions are allowed to the defaults; that is, all of the
-application's actions, L<Jifty::Action::Autocomplete>, and
-L<Jifty::Action::Redirect> are allowed and visible; everything else is denied
-and hidden. See L</restrict> for the details of how limits are processed.
+application's actions, L<Jifty::Action::AboutMe>,
+L<Jifty::Action::Autocomplete>, and L<Jifty::Action::Redirect> are allowed and
+visible; everything else is denied and hidden. See L</restrict> for the details
+of how limits are processed.
=cut
@@ -139,6 +140,7 @@ sub reset {
{ deny => 1, hide => 1, restriction => qr/.*/ },
{ allow => 1, show => 1, restriction => qr/^\Q$app_actions\E/ },
{ deny => 1, hide => 1, restriction => qr/^\Q$app_actions\E::Record::(Create|Delete|Execute|Search|Update)$/ },
+ { allow => 1, show => 1, restriction => 'Jifty::Action::AboutMe' },
{ allow => 1, show => 1, restriction => 'Jifty::Action::Autocomplete' },
{ allow => 1, show => 1, restriction => 'Jifty::Action::Redirect' },
]
@@ -147,10 +149,10 @@ sub reset {
=head2 deny_for_get
-Denies all actions except L<Jifty::Action::Autocomplete> and
-L<Jifty::Action::Redirect>. This is to protect against a common cross-site
-scripting hole. In your C<before> dispatcher rules, you can whitelist actions
-that are known to be read-only.
+Denies all actions except L<Jifty::Action::AboutMe>,
+L<Jifty::Action::Autocomplete> and L<Jifty::Action::Redirect>. This is to
+protect against a common cross-site scripting hole. In your C<before>
+dispatcher rules, you can whitelist actions that are known to be read-only.
This is called automatically during any C<GET> request.
@@ -159,6 +161,7 @@ This is called automatically during any C<GET> request.
sub deny_for_get {
my $self = shift;
$self->deny(qr/.*/);
+ $self->allow("Jifty::Action::AboutMe");
$self->allow("Jifty::Action::Autocomplete");
$self->allow("Jifty::Action::Redirect");
}
diff --git a/lib/Jifty/Action/AboutMe.pm b/lib/Jifty/Action/AboutMe.pm
new file mode 100644
index 0000000..8493c6f
--- /dev/null
+++ b/lib/Jifty/Action/AboutMe.pm
@@ -0,0 +1,44 @@
+use warnings;
+use strict;
+
+=head1 NAME
+
+Jifty::Action::AboutMe - Give information about the current user
+
+=head1 DESCRIPTION
+
+This action is used for external consumers of Jifty's various APIs to get
+information about the current user.
+
+=cut
+
+package Jifty::Action::AboutMe;
+use base qw/Jifty::Action/;
+
+=head2 take_action
+
+Does nothing except set the results to the L<Jifty::CurrentUser> object.
+=cut
+
+sub take_action {
+ my $self = shift;
+
+ $self->result->content(current_user => $self->current_user);
+ $self->report_success;
+
+ return 1;
+}
+
+=head1 SEE ALSO
+
+L<Jifty::Action>, L<Jifty::CurrentUser>
+
+=head1 LICENSE
+
+Jifty is Copyright 2005-2010 Best Practical Solutions, LLC.
+Jifty is distributed under the same terms as Perl itself.
+
+=cut
+
+1;
+
diff --git a/t/TestApp-Plugin-REST/t/02-basic-use.t b/t/TestApp-Plugin-REST/t/02-basic-use.t
index 98ab42c..f29abfd 100644
--- a/t/TestApp-Plugin-REST/t/02-basic-use.t
+++ b/t/TestApp-Plugin-REST/t/02-basic-use.t
@@ -9,7 +9,7 @@ This is a template for your own tests. Copy it and modify it.
=cut
-use Jifty::Test::Dist tests => 87, actual_server => 1;
+use Jifty::Test::Dist tests => 88, actual_server => 1;
use Jifty::Test::WWW::Mechanize;
my $server = Jifty::Test->make_server;
@@ -136,6 +136,7 @@ my @actions = qw(
TestApp.Plugin.REST.Action.SearchUser
TestApp.Plugin.REST.Action.ExecuteUser
TestApp.Plugin.REST.Action.DoSomething
+ Jifty.Action.AboutMe
Jifty.Action.Autocomplete
Jifty.Action.Redirect);
diff --git a/t/TestApp-Plugin-REST/t/03-format.t b/t/TestApp-Plugin-REST/t/03-format.t
index 65f2236..ab54460 100644
--- a/t/TestApp-Plugin-REST/t/03-format.t
+++ b/t/TestApp-Plugin-REST/t/03-format.t
@@ -2,7 +2,7 @@
use warnings;
use strict;
-use Jifty::Test::Dist tests => 103;
+use Jifty::Test::Dist tests => 104;
use Jifty::Test::WWW::Mechanize;
my $server = Jifty::Test->make_server;
@@ -215,6 +215,7 @@ my @actions = qw(
TestApp.Plugin.REST.Action.SearchUser
TestApp.Plugin.REST.Action.ExecuteUser
TestApp.Plugin.REST.Action.DoSomething
+ Jifty.Action.AboutMe
Jifty.Action.Autocomplete
Jifty.Action.Redirect);
-----------------------------------------------------------------------
More information about the Jifty-commit
mailing list