diff --git a/Web/lib/MJB/Web/Controller/Admin.pm b/Web/lib/MJB/Web/Controller/Admin.pm index 9047697..2857b70 100644 --- a/Web/lib/MJB/Web/Controller/Admin.pm +++ b/Web/lib/MJB/Web/Controller/Admin.pm @@ -14,6 +14,7 @@ sub index ( $c ) { # INPUT: # uid | A user id # bid | A blog id belonging to the user +# url | A URL to return to when the admin logs out of the user account # # When given a uid, become that user and go to the user's dashboard. # @@ -21,10 +22,11 @@ sub index ( $c ) { # and go to the blog's dashboard. # sub do_admin_become ( $c ) { - my ( $uid, $bid ) = ( $c->param('uid'), $c->param('bid') ); + my ( $uid, $bid, $url ) = ( $c->param('uid'), $c->param('bid'), $c->param('url') ); $c->session->{oid} = $c->stash->{person}->id; $c->session->{uid} = $uid; + $c->session->{url} = $url if $url; # If we have a blog id, then redirect to that blog's dashboard. # Otherwise, the normal dashboard.. diff --git a/Web/lib/MJB/Web/Controller/Auth.pm b/Web/lib/MJB/Web/Controller/Auth.pm index e70a261..e31b730 100644 --- a/Web/lib/MJB/Web/Controller/Auth.pm +++ b/Web/lib/MJB/Web/Controller/Auth.pm @@ -91,9 +91,14 @@ sub do_logout ( $c ) { # When an admin has impersonated a user, they'll have their uid # stored to oid. When they logout, they are logging out of the # impersonated user's account, back into their own account. + # If a url is set in the session, the admin is returned to that page. if ( $c->session->{oid} ) { $c->session->{uid} = delete $c->session->{oid}; - $c->redirect_to( $c->url_for( 'show_admin' ) ); + if ( $c->session->{url} ) { + $c->redirect_to( $c->url_for( delete $c->session->{url} ) ); + } else { + $c->redirect_to( $c->url_for( 'show_admin' ) ); + } return; } diff --git a/Web/templates/admin/blogs.html.ep b/Web/templates/admin/blogs.html.ep index f1a7cb9..e19070b 100644 --- a/Web/templates/admin/blogs.html.ep +++ b/Web/templates/admin/blogs.html.ep @@ -45,6 +45,7 @@
+
diff --git a/Web/templates/admin/people.html.ep b/Web/templates/admin/people.html.ep index 61485d3..4e4135d 100644 --- a/Web/templates/admin/people.html.ep +++ b/Web/templates/admin/people.html.ep @@ -36,14 +36,15 @@ - % for my $person ( @{$people} ) { + % for my $user ( @{$people} ) { - <%= $person->name %> - <%= $person->email %> - <%= $person->created_at->strftime( "%F" ) %> + <%= $user->name %> + <%= $user->email %> + <%= $user->created_at->strftime( "%F" ) %>
- + +