Some clean-up

This commit is contained in:
swagg boi 2022-11-27 23:56:35 -05:00
parent 9f51c4dad9
commit f7030968d3
3 changed files with 16 additions and 6 deletions

View file

@ -8,8 +8,8 @@ sub login($self) {
my $v;
#Already logged in?
return $self->redirect_to('mod_list')
if $self->session('mod_id') =~ /^\d$/;
return $self->redirect_to('mod_list')
if defined $self->session('mod_id');
$v = $self->validation if $self->req->method eq 'POST';
@ -36,13 +36,15 @@ sub login($self) {
return $self->redirect_to('mod_list');
}
else {
$self->stash(status => 403);
$self->flash(error => 'Invalid login! 🧐')
$self->stash(
status => 403,
error => 'Invalid login! 🧐'
);
}
}
}
$self->render;
return $self->render;
}
sub logout($self) {

View file

@ -15,7 +15,13 @@ my %invalid_login = (
);
subtest Login => sub {
$t->post_ok('/login', form => \%invalid_login)->status_is(403);
$t->get_ok('/login')
->status_is(200)
->text_like(h2 => qr/Moderator Login/);
$t->post_ok('/login', form => \%invalid_login)
->status_is(403)
->text_like(p => qr/Invalid login/);
$t->post_ok('/login', form => \%valid_login)
->status_is(302)

View file

@ -14,6 +14,8 @@
<hr>
<% if (flash 'error') { =%>
<p class="field-with-error" id="error"><%= flash 'error' %></p>
<% } elsif (stash 'error') { =%>
<p class="field-with-error" id="error"><%= stash 'error' %></p>
<% } =%>
<% if (flash 'info') { =%>
<p class="field-with-info" id="info"><%= flash 'info' %></p>