[Rt-commit] rt branch, 4.0/current-user-outdated-email-name-fix, created. rt-4.0.6-219-g2b16197

Alex Vandiver alexmv at bestpractical.com
Wed Jun 27 18:40:57 EDT 2012


The branch, 4.0/current-user-outdated-email-name-fix has been created
        at  2b1619756e89787896f712a3d8cfcd07123d8620 (commit)

- Log -----------------------------------------------------------------
commit 3d790a268916de72dd67bced7ca1c10fad001fef
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed May 25 10:32:01 2011 +0800

    load current user on every request to keep the info up to date

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 91c8ff2..748caa3 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -261,7 +261,15 @@ sub HandleRequest {
 
     $HTML::Mason::Commands::m->comp( '/Elements/SetupSessionCookie', %$ARGS );
     SendSessionCookie();
-    $HTML::Mason::Commands::session{'CurrentUser'} = RT::CurrentUser->new() unless _UserLoggedIn();
+
+    if ( _UserLoggedIn() ) {
+        # make user info up to date
+        $HTML::Mason::Commands::session{'CurrentUser'}
+          ->Load( $HTML::Mason::Commands::session{'CurrentUser'}->id );
+    }
+    else {
+        $HTML::Mason::Commands::session{'CurrentUser'} = RT::CurrentUser->new();
+    }
 
     # Process session-related callbacks before any auth attempts
     $HTML::Mason::Commands::m->callback( %$ARGS, CallbackName => 'Session', CallbackPage => '/autohandler' );

commit bbcd1d812a03d130f0bec8656305a89847493593
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed May 25 11:05:19 2011 +0800

    use CurrentUser->EmailAddress consistently

diff --git a/lib/RT/Interface/Email.pm b/lib/RT/Interface/Email.pm
index 8f38d99..2594e99 100644
--- a/lib/RT/Interface/Email.pm
+++ b/lib/RT/Interface/Email.pm
@@ -787,7 +787,7 @@ sub GetForwardFrom {
     my $ticket = $args{Ticket} || $txn->Object;
 
     if ( RT->Config->Get('ForwardFromUser') ) {
-        return ( $txn || $ticket )->CurrentUser->UserObj->EmailAddress;
+        return ( $txn || $ticket )->CurrentUser->EmailAddress;
     }
     else {
         return $ticket->QueueObj->CorrespondAddress
diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index 306ad4a..3c7eac9 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -1058,7 +1058,7 @@ sub AddWatcher {
         return (0, $self->loc("Couldn't parse address from '[_1]' string", $args{'Email'} ))
             unless $addr;
 
-        if ( lc $self->CurrentUser->UserObj->EmailAddress
+        if ( lc $self->CurrentUser->EmailAddress
             eq lc RT::User->CanonicalizeEmailAddress( $addr->address ) )
         {
             $args{'PrincipalId'} = $self->CurrentUser->id;
diff --git a/share/html/Approvals/Elements/PendingMyApproval b/share/html/Approvals/Elements/PendingMyApproval
index d2061da..169c25c 100755
--- a/share/html/Approvals/Elements/PendingMyApproval
+++ b/share/html/Approvals/Elements/PendingMyApproval
@@ -74,7 +74,7 @@ $tickets->LimitOwner( VALUE => $session{'CurrentUser'}->Id );
 
 # also consider AdminCcs as potential approvers.
 my $group_tickets = RT::Tickets->new( $session{'CurrentUser'} );
-$group_tickets->LimitWatcher( VALUE => $session{'CurrentUser'}->UserObj->EmailAddress, TYPE => 'AdminCc' );
+$group_tickets->LimitWatcher( VALUE => $session{'CurrentUser'}->EmailAddress, TYPE => 'AdminCc' );
 
 my $created_before = RT::Date->new( $session{'CurrentUser'} );
 my $created_after = RT::Date->new( $session{'CurrentUser'} );
diff --git a/share/html/Dashboards/Subscription.html b/share/html/Dashboards/Subscription.html
index 3669e46..3a57102 100644
--- a/share/html/Dashboards/Subscription.html
+++ b/share/html/Dashboards/Subscription.html
@@ -171,7 +171,7 @@
 <&|/l&>Recipient</&>:
 </td><td class="value">
 <input name="Recipient" id="Recipient" size="30" value="<%$fields{Recipient} ? $fields{Recipient} : ''%>" />
-<div class="hints"><% loc("Leave blank to send to your current email address ([_1])", $session{'CurrentUser'}->UserObj->EmailAddress) %></div>
+<div class="hints"><% loc("Leave blank to send to your current email address ([_1])", $session{'CurrentUser'}->EmailAddress) %></div>
 </td></tr>
 </table>
 </&>

commit 0c143a25517dafdcc391af477f10c8f1204fd4cb
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Jun 27 18:37:11 2012 -0400

    Set requestor explicitly, as recipient at example.com is no longer cached
    
    The old 'recipient at example.com' email address was previously incorrectly
    cached in the session, despite the user's email address having been
    changed to 'general at example.com' in the database.  Now that the
    information is reloaded into the session on every request, explicitly
    set the requestor on the tickets such that the test continues to pass.

diff --git a/t/web/crypt-gnupg.t b/t/web/crypt-gnupg.t
index 6bdefda..8c0eb57 100644
--- a/t/web/crypt-gnupg.t
+++ b/t/web/crypt-gnupg.t
@@ -53,6 +53,7 @@ RT::Test->clean_caught_mails;
 
 $m->goto_create_ticket( $queue );
 $m->form_name('TicketCreate');
+$m->field('Requestors', 'recipient at example.com');
 $m->field('Subject', 'Encryption test');
 $m->field('Content', 'Some content');
 ok($m->value('Encrypt', 2), "encrypt tick box is checked");
@@ -122,6 +123,7 @@ RT::Test->clean_caught_mails;
 
 $m->goto_create_ticket( $queue );
 $m->form_name('TicketCreate');
+$m->field('Requestors', 'recipient at example.com');
 $m->field('Subject', 'Signing test');
 $m->field('Content', 'Some other content');
 ok(!$m->value('Encrypt', 2), "encrypt tick box is unchecked");
@@ -195,6 +197,7 @@ RT::Test->clean_caught_mails;
 
 $m->goto_create_ticket( $queue );
 $m->form_name('TicketCreate');
+$m->field('Requestors', 'recipient at example.com');
 $m->field('Subject', 'Crypt+Sign test');
 $m->field('Content', 'Some final? content');
 ok($m->value('Encrypt', 2), "encrypt tick box is checked");
@@ -260,6 +263,7 @@ RT::Test->clean_caught_mails;
 
 $m->goto_create_ticket( $queue );
 $m->form_name('TicketCreate');
+$m->field('Requestors', 'recipient at example.com');
 $m->field('Subject', 'Test crypt-off on encrypted queue');
 $m->field('Content', 'Thought you had me figured out didya');
 $m->field(Encrypt => undef, 2); # turn off encryption

commit 2b1619756e89787896f712a3d8cfcd07123d8620
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue May 24 16:06:02 2011 +0800

    test for updated email of current user

diff --git a/t/web/current_user_outdated_email.t b/t/web/current_user_outdated_email.t
new file mode 100644
index 0000000..51fc803
--- /dev/null
+++ b/t/web/current_user_outdated_email.t
@@ -0,0 +1,41 @@
+
+use strict;
+use warnings;
+use RT::Test tests => 39;
+
+my ( $url, $m ) = RT::Test->started_ok;
+
+$m->login();
+
+my @links = (
+    '/',                                '/Ticket/Create.html?Queue=1',
+    '/SelfService/Create.html?Queue=1', '/m/ticket/create?Queue=1'
+);
+
+my $root = RT::Test->load_or_create_user( Name => 'root' );
+ok( $root->id, 'loaded root' );
+is( $root->EmailAddress, 'root at localhost', 'default root email' );
+
+for my $link (@links) {
+    $m->get_ok($link);
+    $m->content_contains( '"root at localhost"', "default email in $link" );
+}
+
+$root->SetEmailAddress('foo at example.com');
+is( $root->EmailAddress, 'foo at example.com', 'changed to foo at example.com' );
+
+for my $link (@links) {
+    $m->get_ok($link);
+    $m->content_lacks( '"root at localhost"', "no default email in $link" );
+    $m->content_contains( '"foo at example.com"', "new email in $link" );
+}
+
+$root->SetEmailAddress('root at localhost');
+is( $root->EmailAddress, 'root at localhost', 'changed back to root at localhost' );
+
+for my $link (@links) {
+    $m->get_ok($link);
+    $m->content_lacks( '"foo at example.com"', "no previous email in $link" );
+    $m->content_contains( '"root at localhost"', "default email in $link" );
+}
+

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


More information about the Rt-commit mailing list