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

@ -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 $self->session('mod_id') =~ /^\d$/; if defined $self->session('mod_id');
$v = $self->validation if $self->req->method eq 'POST'; $v = $self->validation if $self->req->method eq 'POST';
@ -36,13 +36,15 @@ sub login($self) {
return $self->redirect_to('mod_list'); return $self->redirect_to('mod_list');
} }
else { else {
$self->stash(status => 403); $self->stash(
$self->flash(error => 'Invalid login! 🧐') status => 403,
error => 'Invalid login! 🧐'
);
} }
} }
} }
$self->render; return $self->render;
} }
sub logout($self) { sub logout($self) {

View file

@ -15,7 +15,13 @@ my %invalid_login = (
); );
subtest Login => sub { 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) $t->post_ok('/login', form => \%valid_login)
->status_is(302) ->status_is(302)

View file

@ -14,6 +14,8 @@
<hr> <hr>
<% if (flash 'error') { =%> <% if (flash 'error') { =%>
<p class="field-with-error" id="error"><%= flash 'error' %></p> <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') { =%> <% if (flash 'info') { =%>
<p class="field-with-info" id="info"><%= flash 'info' %></p> <p class="field-with-info" id="info"><%= flash 'info' %></p>