diff --git a/README.md b/README.md index 4d12db6..b01160f 100644 --- a/README.md +++ b/README.md @@ -58,11 +58,9 @@ Run the tests locally (against development environment): ## TODOs -1. Create mod takes null input?? -1. Check status for items not found, should be 404 but getting 5xx +1. Report 404s better (thread by id and remark by id) 1. "All new posts flagged" mode (require approval for new posts) 1. Tests for mod-only user? -1. Check input validation ## Crazy future ideas diff --git a/assets/css/elements.css b/assets/css/elements.css index 9f8de3b..c1a53d9 100644 --- a/assets/css/elements.css +++ b/assets/css/elements.css @@ -7,7 +7,7 @@ --true-gray: #999999; --highlight-green: green; --highlight-red: red; - --transparent: #FFFFFFDD; + --transparent: #FFFFFFBB; box-sizing: border-box; font-size: calc(8px + 1vmin); diff --git a/assets/css/simple.css b/assets/css/simple.css index 307a02c..7935638 100644 --- a/assets/css/simple.css +++ b/assets/css/simple.css @@ -76,6 +76,7 @@ .form-field { display: flex; flex-flow: column; + gap: 0.25em; } .form-field > textarea { @@ -97,13 +98,18 @@ background-color: var(--dark-blue); } -.field-with-info { +.field-with-error { + border: dashed var(--highlight-red); + padding: 0.5em 0.25em; +} + +.stash-with-info { border: dashed var(--highlight-green) 0.5em; padding: 1em; background-color: var(--transparent); } -.field-with-error { +.stash-with-error { border: dashed var(--highlight-red) 0.5em; padding: 1em; background-color: var(--transparent); diff --git a/lib/PostText/Controller/Moderator.pm b/lib/PostText/Controller/Moderator.pm index 6471272..5d152f6 100644 --- a/lib/PostText/Controller/Moderator.pm +++ b/lib/PostText/Controller/Moderator.pm @@ -37,8 +37,8 @@ sub login($self) { $v = $self->validation if $self->req->method eq 'POST'; if ($v && $v->has_data) { - $v->required('email' ); - $v->required('password'); + $v->required('email' )->size(6, 320); + $v->required('password')->size(12, undef); if ($v->has_error) { $self->stash(status => 400) @@ -154,9 +154,9 @@ sub create($self) { $v = $self->validation if $self->req->method eq 'POST'; if ($v && $v->has_data) { - $v->required('name' ); - $v->required('email' ); - $v->required('password'); + $v->required('name' )->size(1, 64); + $v->required('email' )->size(6, 320); + $v->required('password')->size(12, undef); if ($v->has_error) { $self->stash(status => 400) @@ -182,8 +182,8 @@ sub admin_reset($self) { $v = $self->validation if $self->req->method eq 'POST'; if ($v && $v->has_data) { - $v->required('email' ); - $v->required('password'); + $v->required('email' )->size(6, 320); + $v->required('password')->size(12, undef); if ($v->has_error) { $self->stash(status => 400) @@ -208,7 +208,7 @@ sub mod_reset($self) { $v = $self->validation if $self->req->method eq 'POST'; if ($v && $v->has_data) { - $v->required('password'); + $v->required('password')->size(12, undef); if ($v->has_error) { $self->stash(status => 400) @@ -235,7 +235,7 @@ sub lock_acct($self) { $v = $self->validation if $self->req->method eq 'POST'; if ($v && $v->has_data) { - $v->required('email'); + $v->required('email')->size(6, 320); if ($v->has_error) { $self->stash(status => 400) @@ -257,7 +257,7 @@ sub unlock_acct($self) { $v = $self->validation if $self->req->method eq 'POST'; if ($v && $v->has_data) { - $v->required('email'); + $v->required('email')->size(6, 320); if ($v->has_error) { $self->stash(status => 400) @@ -279,7 +279,7 @@ sub promote($self) { $v = $self->validation if $self->req->method eq 'POST'; if ($v && $v->has_data) { - $v->required('email'); + $v->required('email')->size(6, 320); if ($v->has_error) { $self->stash(status => 404) @@ -301,7 +301,7 @@ sub demote($self) { $v = $self->validation if $self->req->method eq 'POST'; if ($v && $v->has_data) { - $v->required('email'); + $v->required('email')->size(6, 320); if ($v->has_error) { $self->stash(status => 404) diff --git a/t/moderator.t b/t/moderator.t index 7152f1b..d60d753 100644 --- a/t/moderator.t +++ b/t/moderator.t @@ -11,7 +11,7 @@ my %valid_login = ( my %invalid_login = ( email => 'fuck@example.com', - password => 'ah fuck' + password => 'ah fuck goddamn' ); subtest Login => sub { diff --git a/t/remark.t b/t/remark.t index fa28d6c..3391e7c 100644 --- a/t/remark.t +++ b/t/remark.t @@ -40,7 +40,7 @@ subtest 'Post new remark', sub { ->text_like(h2 => qr/Thread #1/); $t->post_ok('/remark/post/1', form => \%invalid_remark)->status_is(400) - ->text_like(p => qr/Invalid text/); + ->text_like(p => qr/Must be between/); }; subtest 'Flagging remark', sub { @@ -49,7 +49,7 @@ subtest 'Flagging remark', sub { ->text_like(h2 => qr/Remark #1/); $t->get_ok('/remark/flag/1')->status_is(200) - ->element_exists('p[class="field-with-info"]') + ->element_exists('p[class="stash-with-info"]') ->text_like(p => qr/Remark #1 has been flagged/); }; diff --git a/t/thread.t b/t/thread.t index 8a539e3..191abc0 100644 --- a/t/thread.t +++ b/t/thread.t @@ -66,10 +66,10 @@ subtest 'Post new thread', sub { ->text_like(h2 => qr/New Thread/); $t->post_ok('/thread/post', form => \%invalid_title)->status_is(400) - ->text_like(p => qr/Invalid title/); + ->text_like(p => qr/Must be between/); $t->post_ok('/thread/post', form => \%invalid_post)->status_is(400) - ->text_like(p => qr/Invalid text/); + ->text_like(p => qr/Must be between/); $t->post_ok('/thread/post', form => \%valid_params)->status_is(200) ->text_like(h2 => qr/Thread #\d+/); @@ -85,7 +85,7 @@ subtest 'Bumping thread', sub { ->text_like(h2 => qr/Thread #1/); $t->get_ok('/thread/bump/1')->status_is(200) - ->element_exists('p[class="field-with-info"]') + ->element_exists('p[class="stash-with-info"]') ->text_like(p => qr/Thread #1 has been bumped/); }; @@ -99,7 +99,7 @@ subtest 'Flagging thread', sub { ->text_like(h2 => qr/Thread #1/); $t->get_ok('/thread/flag/1')->status_is(200) - ->element_exists('p[class="field-with-info"]') + ->element_exists('p[class="stash-with-info"]') ->text_like(p => qr/Thread #1 has been flagged/); }; diff --git a/templates/layouts/default.html.ep b/templates/layouts/default.html.ep index e70f251..8095c5c 100644 --- a/templates/layouts/default.html.ep +++ b/templates/layouts/default.html.ep @@ -44,14 +44,14 @@ <% } =%> <% if (flash 'error') { =%> -

<%= flash 'error' %>

+

<%= flash 'error' %>

<% } elsif (stash 'error') { =%> -

<%= stash 'error' %>

+

<%= stash 'error' %>

<% } =%> <% if (flash 'info') { =%> -

<%= flash 'info' %>

+

<%= flash 'info' %>

<% } elsif (stash 'info') { =%> -

<%= stash 'info' %>

+

<%= stash 'info' %>

<% } =%> <%= content =%>