[Bps-public-commit] App-Changeloggr branch, master, updated. 0b280f8a76af4b3ea6279c4401949115c1b3fb9f

Alex M Vandiver alexmv at bestpractical.com
Wed May 20 17:46:28 EDT 2009


The branch, master has been updated
       via  0b280f8a76af4b3ea6279c4401949115c1b3fb9f (commit)
      from  90b3579df60975e95d095ccd1394eec2a31acb85 (commit)

Summary of changes:
 lib/App/Changeloggr/CurrentUser.pm |   15 ---------------
 lib/App/Changeloggr/Dispatcher.pm  |    6 ++++++
 2 files changed, 6 insertions(+), 15 deletions(-)
 delete mode 100644 lib/App/Changeloggr/CurrentUser.pm

- Log -----------------------------------------------------------------
commit 0b280f8a76af4b3ea6279c4401949115c1b3fb9f
Author: Alex Vandiver <alexmv at mit.edu>
Date:   Wed May 20 17:46:14 2009 -0400

    Use a dispatcher rule to set up user_object in a more canonical way
    
    This fixes a bug where current_user->id was always undef, and overriding ->id caused infinite recursion

diff --git a/lib/App/Changeloggr/CurrentUser.pm b/lib/App/Changeloggr/CurrentUser.pm
deleted file mode 100644
index 6e0601a..0000000
--- a/lib/App/Changeloggr/CurrentUser.pm
+++ /dev/null
@@ -1,15 +0,0 @@
-package App::Changeloggr::CurrentUser;
-use strict;
-use warnings;
-use base 'Jifty::CurrentUser';
-
-sub user_object {
-    my $session = Jifty->web->session->id
-        or return;
-    my $user = App::Changeloggr::Model::User->new;
-    $user->load_or_create(session_id => $session);
-    return $user;
-}
-
-1;
-
diff --git a/lib/App/Changeloggr/Dispatcher.pm b/lib/App/Changeloggr/Dispatcher.pm
index 674dc25..ac9ec1d 100644
--- a/lib/App/Changeloggr/Dispatcher.pm
+++ b/lib/App/Changeloggr/Dispatcher.pm
@@ -9,6 +9,12 @@ before '*' => run {
       $top->child(Account => url => '/account');
 
       Jifty->web->session->expires( '+1y' );
+
+      my $session = Jifty->web->session->id
+          or return;
+      my $user = App::Changeloggr::Model::User->new;
+      $user->load_or_create(session_id => $session);
+      Jifty->web->current_user->user_object($user);
 };
 
 on '/admin/created-changelog' => run {

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list