Validation for login and post remark

This commit is contained in:
swaggboi 2024-08-15 21:02:10 -04:00
parent 6b6278e940
commit 2d6152d762
2 changed files with 16 additions and 2 deletions

View file

@ -39,8 +39,15 @@ sub login($self) {
if ($v && $v->has_data) {
$v->required('email' )->size(6, 320);
$v->required('password')->size(12, undef);
$v->csrf_protect;
if ($v->has_error) {
if ($v->has_error('csrf_token')) {
$self->stash(
status => 403,
error => 'Something went wrong, please try again. 🥺'
);
}
elsif ($v->has_error) {
$self->stash(status => 400)
}
else {

View file

@ -36,8 +36,15 @@ sub create($self) {
$v->required('body' )->size(2, $body_limit);
$v->optional('bump' );
$v->optional('preview');
$v->csrf_protect;
if ($v->has_error) {
if ($v->has_error('csrf_token')) {
$self->stash(
status => 403,
error => 'Something went wrong, please try again. 🥺'
)
}
elsif ($v->has_error) {
$self->stash(status => 400)
}
else {