Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117748941
D3137.1775179044.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D3137.1775179044.diff
View Options
diff --git a/src/.env.example b/src/.env.example
--- a/src/.env.example
+++ b/src/.env.example
@@ -16,6 +16,9 @@
APP_WITH_RESELLER=1
APP_WITH_SERVICES=1
+SIGNUP_LIMIT_EMAIL=0
+SIGNUP_LIMIT_IP=0
+
ASSET_URL=http://127.0.0.1:8000
WEBMAIL_URL=/apps
diff --git a/src/app/Rules/ExternalEmail.php b/src/app/Rules/ExternalEmail.php
--- a/src/app/Rules/ExternalEmail.php
+++ b/src/app/Rules/ExternalEmail.php
@@ -37,6 +37,28 @@
return false;
}
+ // don't allow multiple open registrations against the same email address
+ if (env('SIGNUP_LIMIT_EMAIL', 0) > 0) {
+ $signups = \App\SignupCode::where('email', $email)
+ ->whereDate('expires_at', '>', \Carbon\Carbon::now());
+
+ if ($signups->count() >= env('SIGNUP_LIMIT_EMAIL')) {
+ $this->message = \trans('validation.emailinvalid');
+ return false;
+ }
+ }
+
+ // don't allow multiple open registrations against the same source ip address
+ if (env('SIGNUP_LIMIT_IP', 0) > 0) {
+ $signups = \App\SignupCode::where("ip_address", request()->ip())
+ ->whereDate('expires_at', '>', \Carbon\Carbon::now());
+
+ if ($signups->count() >= env('SIGNUP_LIMIT_IP')) {
+ $this->message = \trans('validation.emailinvalid');
+ return false;
+ }
+ }
+
return true;
}
diff --git a/src/app/SignupCode.php b/src/app/SignupCode.php
--- a/src/app/SignupCode.php
+++ b/src/app/SignupCode.php
@@ -99,8 +99,18 @@
*/
public static function generateShortCode(): string
{
- $code_length = env('SIGNUP_CODE_LENGTH', self::SHORTCODE_LENGTH);
+ $codeLength = env('SIGNUP_CODE_LENGTH', self::SHORTCODE_LENGTH);
- return \App\Utils::randStr($code_length);
+ $allegedlyUnique = \App\Utils::randStr($codeLength);
+
+ while ($code = $this->where('short_code', $allegedlyUnique)->first()) {
+ if ($code->isExpired()) {
+ break;
+ }
+
+ $allegedlyUnique = \App\Utils::randStr($codeLength);
+ }
+
+ return $allegedlyUnique;
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Apr 3, 1:17 AM (18 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18821887
Default Alt Text
D3137.1775179044.diff (2 KB)
Attached To
Mode
D3137: Enhance protections in signup in two ways;
Attached
Detach File
Event Timeline