Cleaning up some things; moar tests

This commit is contained in:
swagg boi 2022-11-28 23:33:19 -05:00
parent 10e7944bc3
commit 45614f4035
2 changed files with 9 additions and 2 deletions

View file

@ -9,7 +9,7 @@ sub login($self) {
#Already logged in? #Already logged in?
return $self->redirect_to('mod_list') 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'; $v = $self->validation if $self->req->method eq 'POST';
@ -30,7 +30,10 @@ sub login($self) {
$mod_id = $self->moderator->get_id($email); $mod_id = $self->moderator->get_id($email);
$mod_name = $self->moderator->get_name($mod_id); $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 😎"); $self->flash(info => "Hello, $mod_name 😎");
return $self->redirect_to('mod_list'); return $self->redirect_to('mod_list');

View file

@ -35,6 +35,10 @@ subtest Login => sub {
->status_is(200) ->status_is(200)
->text_like(h2 => qr/Top Secret/); ->text_like(h2 => qr/Top Secret/);
$t->get_ok('/login')
->status_is(302)
->header_like(Location => qr{moderator/list});
$t->get_ok('/logout') $t->get_ok('/logout')
->status_is(302) ->status_is(302)
->header_like(Location => qr{thread/list}); ->header_like(Location => qr{thread/list});