From cf8c32da925790f2b548de40e41b7ce0f613f6ec Mon Sep 17 00:00:00 2001 From: Visman Date: Thu, 8 Oct 2020 19:41:45 +0700 Subject: [PATCH] Change handling of some html forms --- app/Models/Pages/Auth.php | 7 +++++-- app/Models/Pages/Delete.php | 2 +- app/Models/Pages/Edit.php | 1 + app/Models/Pages/Email.php | 1 + app/Models/Pages/Post.php | 1 + app/Models/Pages/Profile/Config.php | 1 + app/Models/Pages/Profile/Edit.php | 1 + app/Models/Pages/Profile/Email.php | 1 + app/Models/Pages/Profile/Mod.php | 1 + app/Models/Pages/Profile/Pass.php | 2 +- app/Models/Pages/Register.php | 1 + app/Models/Pages/Report.php | 1 + 12 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/Models/Pages/Auth.php b/app/Models/Pages/Auth.php index 6626d609db3e1c2456cda4c2496461cefd08e93e..eea81e267974f4b31b633fec97fc562486a5479c 100644 --- a/app/Models/Pages/Auth.php +++ b/app/Models/Pages/Auth.php @@ -47,6 +47,7 @@ class Auth extends Page 'username' => 'required|string', 'password' => 'required|string|login_process', 'save' => 'checkbox', + 'login' => 'required|string', ])->addAliases([ 'username' => 'Username', 'password' => 'Passphrase', @@ -175,8 +176,9 @@ class Auth extends Page $v = $this->c->Validator->reset() ->addValidators([ ])->addRules([ - 'token' => 'token:Forget', - 'email' => 'required|string:trim|email:noban,exists,flood', + 'token' => 'token:Forget', + 'email' => 'required|string:trim|email:noban,exists,flood', + 'submit' => 'required|string', ])->addAliases([ ])->addMessages([ 'email.email' => 'Invalid email', @@ -304,6 +306,7 @@ class Auth extends Page 'token' => 'token:ChangePassword', 'password' => 'required|string|min:16|password', 'password2' => 'required|same:password', + 'submit' => 'required|string', ])->addAliases([ 'password' => 'New pass', 'password2' => 'Confirm new pass', diff --git a/app/Models/Pages/Delete.php b/app/Models/Pages/Delete.php index 3455406ff8b219409cbb0ba40951cac33341c72f..bfe168bfb5fdc8acfd1d79e553607c1684de4ebd 100644 --- a/app/Models/Pages/Delete.php +++ b/app/Models/Pages/Delete.php @@ -33,7 +33,7 @@ class Delete extends Page ->addRules([ 'token' => 'token:DeletePost', 'confirm' => 'integer', // ???? - 'delete' => 'string', + 'delete' => 'required|string', ])->addAliases([ ])->addArguments([ 'token' => $args, diff --git a/app/Models/Pages/Edit.php b/app/Models/Pages/Edit.php index 7feaf4a890e2548e789fc75fdfafeefae847daad..af7fe5fc8c87a759a670faffccf701fd4d5b8237 100644 --- a/app/Models/Pages/Edit.php +++ b/app/Models/Pages/Edit.php @@ -37,6 +37,7 @@ class Edit extends Page if ( $v->validation($_POST) && null === $v->preview + && null !== $v->submit ) { return $this->endEdit($post, $v); } diff --git a/app/Models/Pages/Email.php b/app/Models/Pages/Email.php index b053f8a66bf44c05bb20f331dc71acbcc369b6ca..48d372d3de2e7e1d7656e9f15219aa0b38d127a3 100644 --- a/app/Models/Pages/Email.php +++ b/app/Models/Pages/Email.php @@ -55,6 +55,7 @@ class Email extends Page 'redirect' => 'required|referer:Index', 'subject' => 'required|string:trim|max:70', 'message' => 'required|string:trim,linebreaks|max:65000 bytes', + 'send' => 'required|string', ])->addAliases([ 'subject' => 'Email subject', 'message' => 'Email message', diff --git a/app/Models/Pages/Post.php b/app/Models/Pages/Post.php index 2a0e36ed14efc373182f7ea4161de0d62db924b0..5d1b1edbf98797670ac6c5f66fb9f84b92a91805 100644 --- a/app/Models/Pages/Post.php +++ b/app/Models/Pages/Post.php @@ -38,6 +38,7 @@ class Post extends Page if ( $v->validation($_POST) && null === $v->preview + && null !== $v->submit ) { return $this->endPost($forum, $v); } diff --git a/app/Models/Pages/Profile/Config.php b/app/Models/Pages/Profile/Config.php index 2cf2926580f34ce16be20be5c6ddc33f1dfa70d6..0abfea5a5c820f1c9d0e0d4e9e2a9233091f88cd 100644 --- a/app/Models/Pages/Profile/Config.php +++ b/app/Models/Pages/Profile/Config.php @@ -48,6 +48,7 @@ class Config extends Profile ? '0,1,2' : (int) $this->curUser->ip_check_type ), + 'save' => 'required|string', ])->addAliases([ 'language' => 'Language', 'style' => 'Style', diff --git a/app/Models/Pages/Profile/Edit.php b/app/Models/Pages/Profile/Edit.php index b07585c6b24a016c79a3e11cdaf22827199787f3..b66de5be6529171495a0d8a7eb7bd2ac64deb410 100644 --- a/app/Models/Pages/Profile/Edit.php +++ b/app/Models/Pages/Profile/Edit.php @@ -88,6 +88,7 @@ class Edit extends Profile 'email_setting' => 'required|integer|in:0,1,2', 'url' => $ruleWebsite, 'signature' => $ruleSignature, + 'save' => 'required|string', ])->addAliases([ 'username' => 'Username', 'title' => 'Title', diff --git a/app/Models/Pages/Profile/Email.php b/app/Models/Pages/Profile/Email.php index 9ecbb4ae2b2cfbeffebd99e9d297be639bcb8413..b49bb703a761e29c047030b19df9180a6b42875e 100644 --- a/app/Models/Pages/Profile/Email.php +++ b/app/Models/Pages/Profile/Email.php @@ -62,6 +62,7 @@ class Email extends Profile 'token' => 'token:EditUserEmail', 'password' => 'required|string:trim|check_password', 'new_email' => 'required|string:trim|email:noban,unique,flood', + 'submit' => 'required|string', ])->addAliases([ 'new_email' => 'New email', 'password' => 'Your passphrase', diff --git a/app/Models/Pages/Profile/Mod.php b/app/Models/Pages/Profile/Mod.php index 4041bbbabf1b8aaffe4b2139a5f3c0a53d3bfa55..6ea6759f117f1a83f43e945cb1bce31ea88a49e2 100644 --- a/app/Models/Pages/Profile/Mod.php +++ b/app/Models/Pages/Profile/Mod.php @@ -33,6 +33,7 @@ class Mod extends Profile ])->addRules([ 'token' => 'token:EditUserModeration', 'moderator.*' => 'integer|in:' . \implode(',', \array_keys($this->curForums)), + 'save' => 'required|string', ])->addAliases([ ])->addArguments([ 'token' => ['id' => $this->curUser->id], diff --git a/app/Models/Pages/Profile/Pass.php b/app/Models/Pages/Profile/Pass.php index 1e02a4c0c0c498f2386b9b568ff587ecbe8a0087..f414224e6be93cf14deac360a626acfceb06848e 100644 --- a/app/Models/Pages/Profile/Pass.php +++ b/app/Models/Pages/Profile/Pass.php @@ -34,6 +34,7 @@ class Pass extends Profile 'token' => 'token:EditUserPass', 'password' => 'required|string:trim|check_password', 'new_pass' => 'required|string:trim|password', + 'submit' => 'required|string', ])->addAliases([ 'new_pass' => 'New pass', 'password' => 'Your passphrase', @@ -115,7 +116,6 @@ class Pass extends Profile 'fields' => [ 'new_pass' => [ 'type' => 'password', - 'maxlength' => 25, 'caption' => __('New pass'), 'required' => true, 'pattern' => '^.{16,}$', diff --git a/app/Models/Pages/Register.php b/app/Models/Pages/Register.php index aee366f11e31259bc2ff4140f2baae3dd97fae12..e7223abe95a265f6db191f19439fefcad1206add 100644 --- a/app/Models/Pages/Register.php +++ b/app/Models/Pages/Register.php @@ -27,6 +27,7 @@ class Register extends Page 'email' => 'required_with:on|string:trim|email:noban,unique', 'username' => 'required_with:on|string:trim,spaces|username', 'password' => 'required_with:on|string|min:16|password', + 'register' => 'required|string', ])->addAliases([ 'email' => 'Email', 'username' => 'Username', diff --git a/app/Models/Pages/Report.php b/app/Models/Pages/Report.php index 925822cd9bb138850b6b95275e0f8fc993834738..b7659ee86d298615f8cb7fce9099fa5d363e02be 100644 --- a/app/Models/Pages/Report.php +++ b/app/Models/Pages/Report.php @@ -40,6 +40,7 @@ class Report extends Page ])->addRules([ 'token' => 'token:ReportPost', 'reason' => 'required|string:trim,linebreaks|max:65000 bytes', + 'submit' => 'required|string', ])->addAliases([ 'reason' => 'Reason', ])->addArguments([