From 45614f4035b57a4da5fbfabae8ded2baa1793933 Mon Sep 17 00:00:00 2001 From: swag Date: Mon, 28 Nov 2022 23:33:19 -0500 Subject: [PATCH] Cleaning up some things; moar tests --- lib/PostText/Controller/Moderator.pm | 7 +++++-- t/moderator.t | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/PostText/Controller/Moderator.pm b/lib/PostText/Controller/Moderator.pm index 9016c0f..1f046af 100644 --- a/lib/PostText/Controller/Moderator.pm +++ b/lib/PostText/Controller/Moderator.pm @@ -9,7 +9,7 @@ sub login($self) { #Already logged in? return $self->redirect_to('mod_list') - if defined $self->session('mod_id'); + if defined $self->session->{'mod_id'}; $v = $self->validation if $self->req->method eq 'POST'; @@ -30,7 +30,10 @@ sub login($self) { $mod_id = $self->moderator->get_id($email); $mod_name = $self->moderator->get_name($mod_id); - $self->session(mod_id => $mod_id); + $self->session( + mod_id => $mod_id, + author => $mod_name + ); $self->flash(info => "Hello, $mod_name 😎"); return $self->redirect_to('mod_list'); diff --git a/t/moderator.t b/t/moderator.t index ef55717..ad72e8f 100644 --- a/t/moderator.t +++ b/t/moderator.t @@ -35,6 +35,10 @@ subtest Login => sub { ->status_is(200) ->text_like(h2 => qr/Top Secret/); + $t->get_ok('/login') + ->status_is(302) + ->header_like(Location => qr{moderator/list}); + $t->get_ok('/logout') ->status_is(302) ->header_like(Location => qr{thread/list});