Added REGISTER_IP_CHECK config option
Prevent users from making multiple accounts using the same IP address
This commit is contained in:
parent
a8f455c6c4
commit
823cde9cf9
3 changed files with 62 additions and 40 deletions
|
@ -36,8 +36,8 @@ PHPMYADMIN_URL=https://mysql.bitsec.dev
|
|||
DISCORD_INVITE_URL=https://discord.gg/vrUYdxG4wZ
|
||||
|
||||
#GOOGLE RECAPTCHA
|
||||
RECAPTCHA_SITE_KEY=YOUR_API_SITE_KEY
|
||||
RECAPTCHA_SECRET_KEY=YOUR_API_SECRET_KEY
|
||||
RECAPTCHA_SITE_KEY=6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI
|
||||
RECAPTCHA_SECRET_KEY=6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe
|
||||
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=mailhog
|
||||
|
|
|
@ -8,9 +8,10 @@ use App\Models\Configuration;
|
|||
use App\Models\User;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
|
@ -52,39 +53,50 @@ class RegisterController extends Controller
|
|||
*/
|
||||
protected function validator(array $data)
|
||||
{
|
||||
//check if ip has already made an account
|
||||
$data['ip'] = session()->get('ip') ?? request()->ip();
|
||||
if (User::where('ip', '=', request()->ip())->exists()) session()->put('ip', request()->ip());
|
||||
if (Configuration::getValueByKey('REGISTER_IP_CHECK', 'true') == 'true') {
|
||||
|
||||
//check if ip has already made an account
|
||||
$data['ip'] = session()->get('ip') ?? request()->ip();
|
||||
if (User::where('ip', '=', request()->ip())->exists()) session()->put('ip', request()->ip());
|
||||
|
||||
return Validator::make($data, [
|
||||
'name' => ['required', 'string', 'max:30', 'min:4', 'alpha_num', 'unique:users'],
|
||||
'email' => ['required', 'string', 'email', 'max:64', 'unique:users'],
|
||||
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
||||
'g-recaptcha-response' => ['recaptcha'],
|
||||
'ip' => ['unique:users'],
|
||||
], [
|
||||
'ip.unique' => "You have already made an account with us! Please contact support if you think this is incorrect."
|
||||
]);
|
||||
}
|
||||
|
||||
return Validator::make($data, [
|
||||
'name' => ['required', 'string', 'max:30', 'min:4', 'alpha_num', 'unique:users'],
|
||||
'email' => ['required', 'string', 'email', 'max:64', 'unique:users'],
|
||||
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
||||
'g-recaptcha-response' => ['recaptcha'],
|
||||
'ip' => ['unique:users'],
|
||||
], [
|
||||
'ip.unique' => "You have already made an account with us! Please contact support if you think this is incorrect."
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @return User|\Illuminate\Http\RedirectResponse
|
||||
* @return User
|
||||
*/
|
||||
protected function create(array $data)
|
||||
{
|
||||
$user = User::create([
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'credits' => Configuration::getValueByKey('INITIAL_CREDITS'),
|
||||
'server_limit' => Configuration::getValueByKey('INITIAL_SERVER_LIMIT'),
|
||||
'credits' => Configuration::getValueByKey('INITIAL_CREDITS', 150),
|
||||
'server_limit' => Configuration::getValueByKey('INITIAL_SERVER_LIMIT', 1),
|
||||
'password' => Hash::make($data['password']),
|
||||
]);
|
||||
|
||||
$response = Pterodactyl::client()->post('/application/users', [
|
||||
"external_id" => (string)$user->id,
|
||||
"external_id" => App::environment('local') ? Str::random(16) : (string)$user->id,
|
||||
"username" => $user->name,
|
||||
"email" => $user->email,
|
||||
"first_name" => $user->name,
|
||||
|
@ -96,7 +108,6 @@ class RegisterController extends Controller
|
|||
|
||||
if ($response->failed()) {
|
||||
$user->delete();
|
||||
redirect()->route('register')->with('error', 'pterodactyl error');
|
||||
return $user;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,16 +18,16 @@ class ConfigurationSeeder extends Seeder
|
|||
Configuration::firstOrCreate([
|
||||
'key' => 'INITIAL_CREDITS',
|
||||
], [
|
||||
'value' => '250',
|
||||
'type' => 'integer',
|
||||
'value' => '250',
|
||||
'type' => 'integer',
|
||||
'description' => 'The initial amount of credits the user starts with.'
|
||||
]);
|
||||
|
||||
Configuration::firstOrCreate([
|
||||
'key' => 'INITIAL_SERVER_LIMIT',
|
||||
], [
|
||||
'value' => '1',
|
||||
'type' => 'integer',
|
||||
'value' => '1',
|
||||
'type' => 'integer',
|
||||
'description' => 'The initial server limit the user starts with.'
|
||||
]);
|
||||
|
||||
|
@ -35,33 +35,33 @@ class ConfigurationSeeder extends Seeder
|
|||
Configuration::firstOrCreate([
|
||||
'key' => 'CREDITS_REWARD_AFTER_VERIFY_EMAIL',
|
||||
], [
|
||||
'value' => '250',
|
||||
'type' => 'integer',
|
||||
'value' => '250',
|
||||
'type' => 'integer',
|
||||
'description' => 'Increase in credits after the user has verified their email account.'
|
||||
]);
|
||||
|
||||
Configuration::firstOrCreate([
|
||||
'key' => 'SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL',
|
||||
], [
|
||||
'value' => '2',
|
||||
'type' => 'integer',
|
||||
'value' => '2',
|
||||
'type' => 'integer',
|
||||
'description' => 'Increase in server limit after the user has verified their email account.'
|
||||
]);
|
||||
|
||||
//verify discord event
|
||||
Configuration::firstOrCreate([
|
||||
'key' => 'CREDITS_REWARD_AFTER_VERIFY_DISCORD',
|
||||
] , [
|
||||
'value' => '375',
|
||||
'type' => 'integer',
|
||||
'key' => 'CREDITS_REWARD_AFTER_VERIFY_DISCORD',
|
||||
], [
|
||||
'value' => '375',
|
||||
'type' => 'integer',
|
||||
'description' => 'Increase in credits after the user has verified their discord account.'
|
||||
]);
|
||||
|
||||
Configuration::firstOrCreate([
|
||||
'key' => 'SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD',
|
||||
], [
|
||||
'value' => '2',
|
||||
'type' => 'integer',
|
||||
'value' => '2',
|
||||
'type' => 'integer',
|
||||
'description' => 'Increase in server limit after the user has verified their discord account.'
|
||||
]);
|
||||
|
||||
|
@ -69,8 +69,8 @@ class ConfigurationSeeder extends Seeder
|
|||
Configuration::firstOrCreate([
|
||||
'key' => 'MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER',
|
||||
], [
|
||||
'value' => '50',
|
||||
'type' => 'integer',
|
||||
'value' => '50',
|
||||
'type' => 'integer',
|
||||
'description' => 'The minimum amount of credits the user would need to make a server.'
|
||||
]);
|
||||
|
||||
|
@ -78,25 +78,36 @@ class ConfigurationSeeder extends Seeder
|
|||
Configuration::firstOrCreate([
|
||||
'key' => 'SERVER_LIMIT_AFTER_IRL_PURCHASE',
|
||||
], [
|
||||
'value' => '10',
|
||||
'type' => 'integer',
|
||||
'value' => '10',
|
||||
'type' => 'integer',
|
||||
'description' => 'updates the users server limit to this amount (unless the user already has a higher server limit) after making a purchase with real money, set to 0 to ignore this.',
|
||||
]);
|
||||
|
||||
|
||||
//force email and discord verification
|
||||
Configuration::firstOrCreate([
|
||||
'key' => 'FORCE_EMAIL_VERIFICATION',
|
||||
] , [
|
||||
'value' => 'false',
|
||||
'type' => 'boolean',
|
||||
'key' => 'FORCE_EMAIL_VERIFICATION',
|
||||
], [
|
||||
'value' => 'false',
|
||||
'type' => 'boolean',
|
||||
'description' => 'Force an user to verify the email adress before creating a server / buying credits.'
|
||||
]);
|
||||
|
||||
Configuration::firstOrCreate([
|
||||
'key' => 'FORCE_DISCORD_VERIFICATION',
|
||||
] , [
|
||||
'value' => 'false',
|
||||
'type' => 'boolean',
|
||||
'key' => 'FORCE_DISCORD_VERIFICATION',
|
||||
], [
|
||||
'value' => 'false',
|
||||
'type' => 'boolean',
|
||||
'description' => 'Force an user to link an Discord Account before creating a server / buying credits.'
|
||||
]);
|
||||
|
||||
//disable ip check on register
|
||||
Configuration::firstOrCreate([
|
||||
'key' => 'REGISTER_IP_CHECK',
|
||||
], [
|
||||
'value' => 'true',
|
||||
'type' => 'boolean',
|
||||
'description' => 'Prevent users from making multiple accounts using the same IP address'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue